zoukankan      html  css  js  c++  java
  • c# 消息框代理

    private delegate void SetTextCallback(string text);

    private delegate void SetSelectCallback(object Msge);

    private void SetText(string tt)
    {
    string text = tt;
    try
    {
    if (this.richTextBox1.InvokeRequired)
    {
    SetTextCallback d = new SetTextCallback(SetText);
    this.Invoke(d, new object[] { text });
    }
    else
    {
    if (this.richTextBox1.Lines.Length < Properties.Settings.Default.textclearLength)
    {
    this.richTextBox1.AppendText(text);
    of_SetRichCursor(richTextBox1);
    }
    else
    {
    this.richTextBox1.Clear();
    }
    }
    }
    catch (Exception)
    {
    }
    }

    private void of_SetRichCursor(object msge)
    {
    try
    {
    RichTextBox richbox = (RichTextBox)msge;
    //设置光标的位置到文本尾
    if (richbox.InvokeRequired)
    {
    SetSelectCallback d = new SetSelectCallback(of_SetRichCursor);
    this.Invoke(d, new object[] { msge });
    }
    else
    {
    richbox.Select(richbox.TextLength, 0);
    //滚动到控件光标处
    richbox.ScrollToCaret();
    }
    }
    catch (Exception)
    {
    }
    }

  • 相关阅读:
    区块链:术语
    比特币术语表
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
    我的友情链接
  • 原文地址:https://www.cnblogs.com/ssjsk/p/6362084.html
Copyright © 2011-2022 走看看