Ani*_*oel 11 c# textbox multiline line-numbers
我有一个Multiline richtextbox控件,我想要集成添加行号的功能.我考虑过很多方法
我有两个疑惑.
小智 3
我自己的例子。一切都很好,但必须禁用自动换行:(
int maxLC = 1; //maxLineCount - should be public
private void rTB_KeyUp(object sender, KeyEventArgs e)
{
int linecount = rTB.GetLineFromCharIndex( rTB.TextLength ) + 1;
if (linecount != maxLC)
{
tB_line.Clear();
for (int i = 1; i < linecount+1; i++)
{
tB_line.AppendText(Convert.ToString(i) + "\n");
}
maxLC = linecount;
}
}
Run Code Online (Sandbox Code Playgroud)
其中 rTB 是我的 Richtextbox,tB 是 rTB 旁边的文本框
JT jr