[英]how can i get my added usercontrol properties from flowLayoutPanel
I am using flowLayoutPanel and adding my custom user controls to it, I can add mu usercontrol to it but i don't know how can it use it after adding. 我正在使用flowLayoutPanel并向其添加自定义用户控件,我可以向其中添加mu usercontrol,但是添加后我不知道如何使用它。
in this part i add my user controls: 在这一部分,我添加我的用户控件:
...
ExtensionUserControl extension = new ExtensionUserControl(this, AMI_ClientInstance);
//Add Obj Name (Extension Number)
extension.ExtensionNumber = Obj.ObjName;
flowLayoutPanel1.Controls.Add(extension as ExtensionUserControl);
...
and another place i want to have the properties of my added user control, i try to user this code but it get error, It says that can not convert windows control to ExtensionUserControl 和另一个地方,我想拥有我添加的用户控件的属性,我尝试使用此代码,但是会出错,它说无法将Windows控件转换为ExtensionUserControl
ExtensionUserControl extension = flowLayoutPanel1.Controls[1];
please totally tell me how can i have my user control properties after adding it to panel? 请完全告诉我将其添加到面板后如何拥有用户控件属性?
thanks 谢谢
Are you sure Controls[1] is ExtensionUserControl? 您确定Controls [1]是ExtensionUserControl吗? I think that: 我觉得:
foreach(Control ctl in flowLayoutPanel1.Controls)
{
if(ctl is ExtensionUserControl)
{
(ExtensionUserControl)ctl......//do something u want
}
}
I'm not test it yet, just thinking, sorry if it doesn't work 我还没有测试,只是在想,对不起,如果它不起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.