如何在IDE中执行例程,在属性窗口中更改了用户控件的Enabled属性?

时间:2018-03-12 14:22:41

标签: .net vb.net user-controls ide

定义了两种颜色:

Private goBackColorEnabled As New Color
Private goBackColorDisabled As New Color

在我的用户控件中,我重载Enabled

Private gbEnabled As Boolean

Public Overloads Property Enabled As Boolean
    Get
        Return gbEnabled
    End Get
    Set(bValue As Boolean)
        gbEnabled = bValue
        pRedraw()
    End Set
End Property

我希望通过使用适当的颜色着色用户控件的背景颜色来对Enabled的状态更改做出反应。 (嗯,还有很多工作要做,所以请不要专注于此。)

Private Sub pRedraw()
    'Draw the background color depending on the Enabled state.
    If gbEnabled Then
        Me.BackColor = goBackColorEnabled
    Else
        Me.BackColor = goBackColorDisabled
    End If

    ...
End Sub

创建测试Windows窗体应用程序并将控件放到其上时,我可以在复选框的帮助下在两种颜色之间切换:

Private Sub cChkEnabled_CheckedChanged(sender As Object, e As EventArgs) _
    Handles cChkEnabled.CheckedChanged

    oMyControl.Enabled = cChkEnabled.Checked
End Sub

在使用所选用户控件更改属性窗口中的pRedraw值时,如何在IDE中执行Enabled例程?

0 个答案:

没有答案