Reputation: 79
I want to show all usercontrols in window forms I add usercontol in window form and try to show them using show() method. but nothing is Shown up on the window. Can any one please tell how to do this.
I am having following troubled code (in C#)
private void patientform_Load(object sender, EventArgs e)
{
patient p = new patient();
patientform patienfrm = new patientform();
patienfrm.Controls.Add(p);
patienfrm.Show();
Control[] ctrl = this.Controls.Find("textBox1", true);
//String c = ctrl[0].Text;
//label1.Text = c;
Upvotes: 0
Views: 504
Reputation: 5600
You care creating a new instance of same form which is already loaded. You need to refer to correct instance of the form.
I suppose you are trying to add Patient control to PatientForm. Following code would do that:
Controls.Add(new Patient());
You will have to set position and other properties to show it in right place with right anchoring and docking etc.
Upvotes: 1