Identification of the management container (GroupBox, etc.) Dynamically

I dynamically generate a Windows Forms form by reading an XML file. (Actually, I have a separate tool designed to serialize a Windows Forms form and its components.)

How do I know in which container each control is managed?

For example, if I dynamically create a label that I want to find if it is inside a group field or any container. Is there any property available for this?

+3
source share
4 answers

It will be mycontrol.Parent.

+4
source
+6
source

.NET controls have a property called Parent. The controls inside the group pane are set as the parent name as the group name.

+1
source

Firstly, you can find the group field, for example, for example:

groupbox x

After that, find the label, for example

(Label) x.findControl("labelID"). 

You can try this as follows.

0
source

Source: https://habr.com/ru/post/1780823/


All Articles