Set property

fresh

New member
Joined
Apr 16, 2005
Messages
1
Programming Experience
Beginner
Set property HELP!!!!

How to set a property and trigger error message when user try to set it again

?
 
Last edited:
If this property has an event associated with its value changing, use the event handler to display your message. You may need to set a flag the first time the property is set if you intend to let the user make one change. For example:
VB.NET:
Dim buttonEnabledSet As Boolean = False

Private Sub button1_EnabledChanged(sender As Object, e As EventArgs) Handles button1.EnabledChanged
    If buttonEnabledSet Then
        button1.Enabled = Not button1.Enabled
        MessageBox.Show("Button.Enabled property has already been set.")
    Else
        buttonEnabledSet = True
    End If
End Sub
 
Back
Top