Using Property Grid in C# |
Post Reply |
Author | |
lpereira
Newbie Joined: 21 February 2005 Status: Offline Points: 2 |
Post Options
Thanks(0)
Posted: 21 February 2005 at 4:52pm |
I am using the property grid in a c#application. I need to be able to validate data that a user enters for a propertygrid item and then notify the user if its invalid data. I added the valuechanged event to my code, however there is no way to identify which item was the one modified. Is there a way to do this? Thanks. |
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
I don't have the documents in front of me right now, but I believe the EventArgs for the 'ValueChanged' event will include a reference to the item that was modified.
|
|
ianp
Moderator Group Joined: 19 December 2003 Location: United Kingdom Status: Offline Points: 119 |
Post Options
Thanks(0)
|
The ValueChanged event in VB6 should be:
|
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
I finally got back in front of a PC with Codejock installed, so here's an update about detecting a value change in C#. Indeed, the 'item' that was changed is exposed in the event args. An event handler might look like the following:
Edited by Boyd |
|
bluelizard
Newbie Joined: 24 March 2005 Status: Offline Points: 2 |
Post Options
Thanks(0)
|
I'm using PropertyGrid in C# too. The main problem with the
ValueChanged event, as currently implemented, is that it's not that
easy to find out what the value was
before it was edited, so that if the data entered is invalid, you can
set it back. My hack around it is to store the current data value
in the Tag property, and upon validation, change the value of the Tag
property, otherwise reset the value back to what's in the Tag
property. Kinda hackish, but whatever works.
BlueLizard |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |