I am trying to use UserControl in panel of windows form. But it is not being showed.
Method of the form:
public void SetContent(UserControl control) {
contentPanel.Controls.Clear();
control.Dock = DockStyle.Fill;
contentPanel.Controls.Add(control);
control.Show();
contentPanel.Show();
control.Refresh();
contentPanel.Refresh();
Refresh();
}
Initialization
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MyForm form;
Application.Run(form=new MyForm());
form.SetContent(new MyControl());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.