textbox允许有滚动条的属性是什么?
右边属性查找ScrollBars 设置为 Vertical 或者both.
var textBox8897 = textBox3;
//多行
textBox8897.Multiline = true;
//不自动换行
textBox8897.WordWrap = false;
//添加滚动条,, ScrollBars.Horizontal=横,ScrollBars.Vertical=竖,
textBox8897.ScrollBars = ScrollBars.Vertical;
//textbox滚动条保持在最下面
textBox8897.TextChanged += (sender, args) =>
{
if (textBox8897.MaxLength <= textBox8897.Text.Length) //防止内存溢出
{
textBox8897.Text = "";
}
textBox8897.SelectionStart = textBox8897.Text.Length;
textBox8897.SelectionLength = 0;
textBox8897.ScrollToCaret();
};
//向textbox追加内容,不闪烁
textBox1.AppendText(str);
//换行符
"\r\n"
//行高
txtTest.AutoSize = false;
txtTest.Height = 18;
//多线程赋值
public static void AppendShow(this TextBox textBox2, string showText)
{
if (textBox2.MaxLength <= textBox2.Text.Length) //防止内存溢出
{
textBox2.Text = "";
}
var textBox888 = textBox2;
if (textBox888.InvokeRequired)//等于true 表示有其他线程要访问 就用委托.
{
Action<string> actionDelegate = (txt) => { textBox888.AppendText("\r\n" + txt + "\r\n"); };
textBox888.Invoke(actionDelegate, showText);
}
else
{
textBox888.AppendText("\r\n" + showText + "\r\n");
}
}
public static void SetShow(this TextBox textBox2, string showText)
{
if (textBox2.MaxLength <= textBox2.Text.Length ) //防止内存溢出
{
textBox2.Text = "";
}
var textBox888 = textBox2;
if (textBox888.InvokeRequired)//等于true 表示有其他线程要访问 就用委托.
{
Action<string> actionDelegate = (txt) => { textBox888.Text=("\r\n" + txt + "\r\n"); };
textBox888.Invoke(actionDelegate, showText);
}
else
{
textBox888.Text=("\r\n" + showText + "\r\n");
}
}