Пример #1
0
        private void TextBoxChangeLockState(TextBox textbox)
        {
            if (textbox.InvokeRequired)
            {
                var t = new TextBoxDelegate(TextBoxChangeLockState);

                this.Invoke(t, new object[] { textbox });
            }
            else
            {
                textbox.ReadOnly = !textbox.ReadOnly;
            }
        }
Пример #2
0
 public void InputLog(string text)
 {
     if (!richTextBox1.InvokeRequired)
     {
         richTextBox1.SelectionStart  = richTextBox1.TextLength;
         richTextBox1.SelectionLength = 0;
         richTextBox1.SelectionColor  = Color.DarkRed;
         richTextBox1.AppendText(text + "\r\n");
         richTextBox1.SelectionColor = Color.Black;
     }
     else
     {
         TextBoxDelegate d = InputLog;
         this.Invoke(d, new object[] { text });
     }
 }
Пример #3
0
 /// <summary>在textBox中追加信息,因为在其他线程无法操作主线程的控件,所以需要用这种方法<</summary>
 /// <param name="str">要追加的信息</param>
 public void AddItemToTextBox(string str)
 {
     try
     {
         if (textBox.InvokeRequired)
         {
             TextBoxDelegate d = AddItemToTextBox;
             textBox.Invoke(d, str);
         }
         else
         {
             textBox.AppendText(str + "\r\n");
         }
     }
     catch
     {
     }
 }
 public DesktopLogbookTest()
 {
     InitializeComponent();
     textBoxDelegate = new TextBoxDelegate(TextHelper.UpdateTextBox);
     displayMessage = new LogMessageEventHandler(UpdateLogText);
 }