Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Gurus*
Posted
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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

  • *Experts*
Posted

Put this in PropertyValueChanged event:

       If e.ChangedItem.Label = "nameofyourproperty" Then
           Try
               Integer.Parse(e.ChangedItem.Value)
           Catch ex As Exception
               MsgBox("No numbers!")
           End Try
       End If

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...