在另一个子控件中使用子控件属性 [英] using child control properties in another child controls
问题描述
我正在使用TableLayoutPanel作为表。每个表格单元格都有面板控件。一些Panel控件中有Label控件。
当我想使用PANEL控件时,我可以使用
Dim ipanel as panel = TryCast (TableLayoutPanel.Getcontrolfromposition(i,j),panel)
ipanel.backcolor = color.gray ' 例如
我可以在for-next语句中使用所有这样的CHILD PANEL属性。但是,TableLayoutPanel中的一些子PANEL控件中还有其他Label控件。
如何在此处使用LABEL控件属性?
我必须用于下一次扫描TableLayoutPanel的所有单元格。因此,我需要达到
ilable = ipanel.controls (我知道写这里不正确,只是为了解释我需要的东西)
提前致谢
好的。我找到了解决方案:)
Dim c As Control = Me .TableLayoutPanel1.GetControlFromPosition(i,j)
如果 c.HasChildren()那么
Dim pt As Point
Dim L As Control = c。 GetChildAtPoint(pt)
L.Text = c.Tag
结束 如果跨度>
I'm using TableLayoutPanel as table. Each Table cells has panel controls. Some Panel controls has Label control in it.
When I want to use PANEL controls, I can use
Dim ipanel as panel = TryCast(TableLayoutPanel.Getcontrolfromposition(i,j),panel)
ipanel.backcolor = color.gray ' for example
I can use all CHILD PANEL properties like this in for-next statements. But also, some of child PANEL Controls in the TableLayoutPanel, has other Label controls in it.
How can I use the LABEL controls properties here as?
I have to use for next to scan for all cells of TableLayoutPanel. therefore, I need to reach as
ilable = ipanel.controls (I know writing here is not correct, just to explain What I needed)
Thanks in advance
Ok. I found solution :)
Dim c As Control = Me.TableLayoutPanel1.GetControlFromPosition(i, j) If c.HasChildren() Then Dim pt As Point Dim L As Control = c.GetChildAtPoint(pt) L.Text = c.Tag End If
这篇关于在另一个子控件中使用子控件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!