Basically, I want to change a textbox's property inside class1
, while class1
has an instance in that textbox's form. After my attempt a System.InvalidOperationException
was thrown.
Would anyone help me?
public partial class mainForm : Form
{
class1 c1;
public mainForm()
{
InitializeComponent();
c1 = new class1(this);
}
}
class class1
{
mainForm mF;
public class1(mainForm mF)
{
this.mF = mF;
}
public void change()
{
mF.textBox1.Text = "Done!"; // I think the problem is here, but dunno why
}
}
In addition, change() was called implicitly by c1(eg. not like c1.change()).But i call c1.general(), then c1.general() invoke c1.change().