QuicK Help Please Rich Textbox Problem!!!
Why doesn`t this work. Im trying to use this when getting information from a serial port it works to get info send but when it tries for the incoming it gives me an error of:
Cross-thread operation not valid: Control 'rtfTerminal' accessed from a thread other than the thread it was created on.
rtfTerminal is a rich textbox
This is my code:
Code:
Private Sub Log(ByVal msgtype As LogMsgType, ByVal msg As String)
rtfTerminal.SelectedText = String.Empty
rtfTerminal.SelectionFont = New Font(rtfTerminal.SelectionFont, FontStyle.Bold)
rtfTerminal.SelectionColor = LogMsgTypeColor(CInt(msgtype))
rtfTerminal.AppendText(msg)
rtfTerminal.ScrollToCaret()
End Sub
Re: QuicK Help Please Rich Textbox Problem!!!
You can not access a control from a thread other than the one on which it was created. Take a look at this thread by jmcilhinney the subject.