Is het possible to have one instance of a usercontrol running on two different forms?
I did the following and it did not work (the controls only shows up at the last form).
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var control = new UserControl1();
var form2 = new Form2();
form2.UserControl1 = control;
form2.Show();
var form1 = new Form1();
form1.UserControl1 = control;
Application.Run(form1);
}
I would have to say no. At least under normal .Net operation. If I create a textbox and add it to form1, then add the same textbox instance to form2, the textbox in form1 literally moves to form2. Even if it worked, properties like location, parentform, etc. would be borked between the two forms.
If you need to have common instance data, a class singleton might fit the bill.