WPF里TextBox显示行号
2020-12-29 15:28
标签:ica mamicode ons numbers http show round question 技术 参考文档: https://stackoverflow.com/questions/15610940/show-linenumbers-from-the-richtextbox-in-wpf 效果: 前台: 后台: 源码: https://files.cnblogs.com/files/lizhijian/2020-12-23-WPF%E9%87%8CTextBox%E6%98%BE%E7%A4%BA%E8%A1%8C%E5%8F%B7.zip WPF里TextBox显示行号 标签:ica mamicode ons numbers http show round question 技术 原文地址:https://www.cnblogs.com/lizhijian/p/14179679.html public TextBoxWithLineNumber()
{
InitializeComponent();
InfoTbx.Loaded += delegate
{
//当加载后,行号才有效
InfoTbx_OnTextChanged(InfoTbx, null);
};
}
public string GetInputInfo()
{
return InfoTbx.Text;
}
public void SetIsReadOnly(bool isReadOnly)
{
InfoTbx.IsReadOnly = isReadOnly;
}
public void SetTextInfo(string txt)
{
InfoTbx.Text = txt;
}
private void InfoTbx_OnTextChanged(object sender, TextChangedEventArgs e)
{
var textBox = sender as TextBox;
var x = string.Empty;
for(var i = 0; i 2000; i++)
{
x += i + 1 + "\n";
}
LineNumberTextBlock.Text = x;
}