请教一个有关UserControl的问题
自定义控件中有许多的label,想为控件添加一个lblBackColor属性,用于在设计时和运行时设置自定义控件中所有label的BackColor,不知道如何实现,请大家指教。
[解决办法]
Dim obj As Object
Dim lbl As Label
For Each obj In Controls
If TypeOf obj Is VB.Label Then
Set lbl = obj
lbl.BackColor = vbRed
End If
Next
[解决办法]
Dim obj As Object
For Each obj In Controls
If TypeOf obj Is VB.Label Then
obj.BackColor = vbRed
End If
Next
[解决办法]
他们说的没错,只是你要写在恰当的位置就行了:
Public Property Let lblBackColor(ByVal New_lblBackColor As OLE_COLOR)
m_lblBackColor = New_lblBackColor
PropertyChanged "lblBackColor "
Dim obj As Object
For Each obj In Controls
If TypeOf obj Is VB.Label Then
obj.BackColor = m_lblBackColor
End If
Next
End Property