1

I'm trying to create a inherited control. I made a boolean public property for this control titled "Flickering" to enable/disable the flickering effects on the control.

Then what I want is to "turn on" the next overridable property only when the "Flickering" property is enabled, but I don't have idea of how to do this:

Protected Overrides ReadOnly Property CreateParams() As CreateParams
If Disable_Flickering = True Then
    Get
        Dim cp As CreateParams = MyBase.CreateParams
        cp.ExStyle = cp.ExStyle Or &H2000000
        Return cp
    End Get 
End If
End Property

The code obviously does not work but also I think I'm not thinking in the correct logic to do this.

How I can do it?

ANSWER:

''' <summary>
''' Enable/Disable any flickering effect on the panel.
''' </summary>
Protected Overrides ReadOnly Property CreateParams() As CreateParams
    Get
        If _Diable_Flickering Then
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or &H2000000
            Return cp
        Else
            Return MyBase.CreateParams
        End If
    End Get
End Property
4

1 回答 1

6

不可能有条件可见的属性。如果有人在对象处于不适当状态时尝试更改或获取值,您也可以抛出异常。

于 2013-06-05T19:41:53.527 回答