DesignTimeSupport for TableLayoutPanel with dynamic added controls in each cell
-
Hi I hope you can help me I'm trying to create my own control to support the following: It should be a table/grid (row X cells) where each cell can contain a textfield/label/button/checkbox etc. So I created my own Control extending the TableLayoutPanel and added a textfield for each cell in the constructor of my control. When I add my own TableControl in my hosted Designer to my form then I'm only able to access the properties of the TableLayoutPanel. But I cannot select each Textfield in the cells in the TableLayoutPanel seperately to change those properties. If I only add the TableLayoutPanel to my form and consequently add all the textfields to the cells, then I'm able to select those textfields seperately. How can I implement those behaviour, when the tableLayoutPanel must not get created wit empty cells (every cell must contain a control and the control must be able to get selected to change the properties). If there is a better choice than the TableLayoutPanel for my planned behaviour. I hope you can understand my intention. Thanks in advance
-
Hi I hope you can help me I'm trying to create my own control to support the following: It should be a table/grid (row X cells) where each cell can contain a textfield/label/button/checkbox etc. So I created my own Control extending the TableLayoutPanel and added a textfield for each cell in the constructor of my control. When I add my own TableControl in my hosted Designer to my form then I'm only able to access the properties of the TableLayoutPanel. But I cannot select each Textfield in the cells in the TableLayoutPanel seperately to change those properties. If I only add the TableLayoutPanel to my form and consequently add all the textfields to the cells, then I'm able to select those textfields seperately. How can I implement those behaviour, when the tableLayoutPanel must not get created wit empty cells (every cell must contain a control and the control must be able to get selected to change the properties). If there is a better choice than the TableLayoutPanel for my planned behaviour. I hope you can understand my intention. Thanks in advance
I believe that to achieve the results you want you will have to implement a custom designer for your new control. This article may give you a start Designing Nested Controls[^]. At the very least it should give you some terms to search on (
ParentControlDesigner
for example). If that does not lead you to a solution then you could 'surface' the properties of the internal controls (see snippet below). This will not allow them to be selected but will at least allow their properties to be set.class MyPanel : TableLayoutPanel { public string NameText { get { return myNameTextBox.Text; } set { myNameTextBox.Text = value; } } }
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
I believe that to achieve the results you want you will have to implement a custom designer for your new control. This article may give you a start Designing Nested Controls[^]. At the very least it should give you some terms to search on (
ParentControlDesigner
for example). If that does not lead you to a solution then you could 'surface' the properties of the internal controls (see snippet below). This will not allow them to be selected but will at least allow their properties to be set.class MyPanel : TableLayoutPanel { public string NameText { get { return myNameTextBox.Text; } set { myNameTextBox.Text = value; } } }
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”