PropertyGrid value validation?

Erikvandervelde

Newcomer
Joined
May 23, 2003
Messages
11
Hi there!

I'm using a propertyGrid on my form to change the properties of some objects.
When I have an integer-property. I'm 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' aren't fired.
Does anybody has a solution for my problem?

Regards,

Erik van der Velden.
Holland
 
As far as I'm aware the propertygrid doesn't offer this level of interaction. You'll probably have to make do with the fact that they can type in letters, but it won't actually let them apply them to a numeric data type.
 
Put this in PropertyValueChanged event:
Visual Basic:
        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