rfresh
Active member
- Joined
- Aug 23, 2012
- Messages
- 26
- Programming Experience
- 1-3
I'm a fairly new C# programmer. I have a serialPort component I am using to 'talk' to a controller board.
I found the code example below and I am using it...it seems to be working fine. When I send a cmd to my device, what it returns is displayed in my richTextBoxReceiveWindow1 component.
What I'd like to do now, is add a second richTextBox to also receive the same data. I'm not sure how to do that?
Thank you for any help...
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
		
			
		
		
	
				
			I found the code example below and I am using it...it seems to be working fine. When I send a cmd to my device, what it returns is displayed in my richTextBoxReceiveWindow1 component.
What I'd like to do now, is add a second richTextBox to also receive the same data. I'm not sure how to do that?
Thank you for any help...
			
				C#:
			
		
		
		        private delegate void SetTextDeleg(string text);
        private void si_DataReceived(string data) { richTextBoxReceiveWindow1.Text = data.Trim(); }
        void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            Thread.Sleep(500);
            string data = serialPort.ReadExisting();
            // Invokes the delegate on the UI thread, and sends the data that was received to the invoked method.
            // ---- The "si_DataReceived" method will be executed on the UI thread which allows populating of the textbox.
            this.BeginInvoke(new SetTextDeleg(si_DataReceived), new object[] { data });
        } 
	 
 
		 
 
		 
 
		