I’m trying to update a text box from a class called ‘hex’ to the main form. Within the class ‘hex’ I have the following code:
Main m = new Main();
m.updateTextBox(convertedHex);
the code passed the variable to the main form to the method called ‘updateTextBox’ as shown below:
public void updateLog(string input)
{
textBox2.AppendText(input);
}
Sorry if this seems like a silly questions I have been stuck for a while, all the links on my google searches are now purple so I was hoping if someone could explain this to me. Many thanks.
Add this kind of method inside your Main class where textBox is created and call it from outside.
Lets say you added the code in your
Program.csclass to start newCall it like:
Program.MainLogWindow.UpdateTextBox("test test");from anywhere assuming that you haveMainLogWindowopenThis will also allow you to call updates from within other threads.