Why are you announcing a new instance of your form? Just use your txLabel form
In C #:
this.txLabel.Text = "testing";
In vb.net:
Me.txLabel.Text = "testing"
In the code example you provided, you create a new instance / link to your actual form. Use an existing instance, in addition, use this , not a new instance.
I had to change my question as I noticed that you are using a static method.
Try the following:
public static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) { Form1 f = (Form1) sender; f.textBox1.Text = "testing"; } private void button1_Click(object sender, EventArgs e) { DataReceivedHandler(this, null); }
Of course, I just call DataReceivedHandler() from the button event, you can call it from your own event. Point - you need to pass the current instance of this to the function. When a new instance of the form is not created inside the function, just set the link to the current form and use this link to apply the settings to the property (txtBox or Label or something else).
source share