在winforms中动态加载控件详细信息 [英] Getting Control details loaded in Panel dynamically in winforms
问题描述
我在Winform中有一个面板,它在方法调用期间在运行时加载面板。使用以下代码完成:
I am having a panel in Winform which loads panels in to it in run time during a method call. It is done using below code:
//Adding a child panel
Panel p = new Panel();
//Adding controls to panel
Label lbl5 = new Label();
lbl5.Location = new Point(105, 3);
lbl5.Text = note.noteName;
Label lbl6 = new Label();
lbl6.Location = new Point(105, 43);
lbl6.Text = note.noteName;
//Adding child panel to main panel
Panel1.Controls.Add(p);
通过这种方式调用方法时,新的子面板将添加到主面板。< br $>
我的要求是,当用户点击主面板中的子面板时,需要子面板详细信息...之后,子面板中存在控件的值。 ..当我动态加载子面板时,我可以为子面板做任何方法调用()吗?
任何建议!!!
In this way whenever the method is called a new child panel will be added to main panel.
My requirement is whenever user clicks on a child panel in the main panel, the child panel detail is required...after that the value of controls present in child panel...As i am loading child panel dynamically, can i do any method call() for child panel ???
Any suggestion !!!
推荐答案
是的,您可以通过父控件的名称
找到控件。
使用< a href =http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.find%28VS.80%29.aspx> Control.ControlCollection.Find。 [ ^ ]
Yes, you can find the control by itsname
from the parent control.
Use Control.ControlCollection.Find.[^]
var ctrl = Panel1.Controls["Your Control Name"];
< br $> b $ b
-KR
-KR
这篇关于在winforms中动态加载控件详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!