PropertyGrid value validation?

Joined
May 23, 2003
Messages
11
Hi there!

Im using a propertyGrid on my form to change the properties of some objects.
When I have an integer-property. Im still able to type non-numeric characters as a value in the propertygrid. The result is that the class gives back an exception.
How can I prevent numeric values typed in this textbox?
Events such as keydown and keyup arent fired.
Does anybody has a solution for my problem?

Regards,

Erik van der Velden.
Holland
 
As far as Im aware the propertygrid doesnt offer this level of interaction. Youll probably have to make do with the fact that they can type in letters, but it wont actually let them apply them to a numeric data type.
 
Put this in PropertyValueChanged event:
Code:
        If e.ChangedItem.Label = "nameofyourproperty" Then
            Try
                Integer.Parse(e.ChangedItem.Value)
            Catch ex As Exception
                MsgBox("No numbers!")
            End Try
        End If
 
Back
Top