如何通过单击按钮从Form1中显示UserControl [英] How to Show UserControl from Form1 by clicking the button
问题描述
尊敬的先生/女士:
我的C#项目中有一个Form1.在这个项目中,我添加了一个UserControl.现在我的问题是:
如何通过单击按钮
从Form1中显示UserControl
(相似之处例如:例如...)
form1 frm = new form1();
frm.show();
但是对于UserControl,这是行不通的.
请任何帮助都将非常有用.
在此先感谢
Roni
MyUserControl myControl1 = new MyUserControl();
frm.Controls.Add(myControl1);
尝试:MyUserControl muc = new MyUserControl(); muc.Location = pointIWantItAt; Controls.Add(muc);这会将用户控件添加到当前类(窗体)控件列表中,这将使其可见.
Dear Sir/Madam
I have a Form1 in my C# Project. Within this project I haved added a UserControl. Now my question is:
How can i show the UserControl from Form1 by clicking the button,
(the similarity would be like: e.g...)
form1 frm = new form1();
frm.show();
But for UserControl this is not working.
Please any help would be very greatfull.
Thanks in advance
Roni
MyUserControl myControl1 = new MyUserControl();
frm.Controls.Add(myControl1);
Try:MyUserControl muc = new MyUserControl(); muc.Location = pointIWantItAt; Controls.Add(muc);This add the user control to the current class (form) Controls list, and this will make it visible.
这篇关于如何通过单击按钮从Form1中显示UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!