请教一个修改控件集的办法
在一个tabcontrol中我在每个tabpage中有很多label控件
我想一次性修改这些label控件的对象
例如把这些控件的背景颜色改成白色
我有写了一个不过没有调通,请指教
Dim olabel As Control
For Each olabel In Me.TabControl1.TabPages
CType(olabel, Label).BackColor = Color.White
Next
但是不能达到预期的效果。。。
[解决办法]
你的olabel得到的是TabPage对象,应该再在它的Controls里面循环得到Label空间.
For Each page As TabPage In Me.TabControl1.TabPages For Each c As Control In page.Controls If c.GetType() Is GetType(Label) Then c.BackColor = Color.Red End If Next Next