WinForm TextBox

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");
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值