简体   繁体   English

我如何从flowLayoutPanel获取添加的usercontrol属性

[英]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.

相关问题 从FlowLayoutPanel中选择UserControl - Select UserControl from FlowLayoutPanel 如何从另一个类访问userControl中的某些属性? - How can I access some properties in userControl from another class? 如何向UserControl添加一些属性? - How can i add some properties to UserControl? 滚动问题-用户控件中的Datagridview,已将用户控件实例添加到Flowlayoutpanel - Scroll issue - Datagridview in Usercontrol, Usercontrol instances added to Flowlayoutpanel 如何获得是否将控件添加到我的UserControl ControlsCollection的指示? - how to get an indication if a control was added to my UserControl ControlsCollection? 如何连接UserControl属性,使其在回发时保持状态? - How can I connect up my UserControl properties in such a way that they retain state on postback? 如何在 TabPage 中添加 FlowLayoutPanel 和 PictureBox? - How can I add FlowLayoutPanel and PictureBox in TabPage? 如何确定哪个UserControl在FlowLayoutPanel的顶部? - How to determine which UserControl is at the top of a FlowLayoutPanel? 如何将控件移动到页面中动态添加的用户控件中? - How can I move controls into a dynamically added usercontrol into page? 如何使用foreach将模型中的属性输入到视图中? - How can I get my properties from a Model into my View with a foreach?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM