gaishitaibao 发表于 2012-6-18 09:58:00

急急急,如何在TX中显示行号啊

急急急,如何在TX中显示行号啊,如图所示:

iceman 发表于 2012-6-18 10:41:00

回复 1楼gaishitaibao的帖子

实现方法如下:

private Brush LINE_COLOR = new SolidBrush(Color.Gray);
      private int LINE_DISTANCE = 40;

      private void linenumberToolStripMenuItem_Click(object sender, EventArgs e)
      {
            textControl1.Refresh(); Graphics g = textControl1.CreateGraphics();
            int DPI = (int)(1440 / g.DpiX); foreach (TXTextControl.Line line in textControl1.Lines) { g.DrawString(line.Number.ToString() + ":", new Font(textControl1.Font.Name, textControl1.Font.Size), LINE_COLOR, new PointF(((line.TextBounds.X / DPI) - LINE_DISTANCE) - (textControl1.ScrollLocation.X / DPI), (line.TextBounds.Top / DPI) - (textControl1.ScrollLocation.Y / DPI))); }
      }

gaishitaibao 发表于 2012-6-18 11:20:00

回复 2楼iceman的帖子

非常感谢,但是好像只能一次显示有限的行数,显示后面的行数时,前面的自动消失了,怎样才能让所有的行号都一直保持呢?

iceman 发表于 2012-6-18 11:38:00

回复 3楼gaishitaibao的帖子

楼主可以在:textControl1_InputPositionChanged 事件中添加该方法。
页: [1]
查看完整版本: 急急急,如何在TX中显示行号啊