Print Page | Close Window

Using Property Grid in C#

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=1831
Printed Date: 27 April 2024 at 4:46pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Using Property Grid in C#
Posted By: lpereira
Subject: Using Property Grid in C#
Date 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.




Replies:
Posted By: Boyd
Date Posted: 21 February 2005 at 6:39pm
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.


Posted By: ianp
Date Posted: 22 February 2005 at 3:27am

The ValueChanged event in VB6 should be:

Private Sub PropertyGrid1_ValueChanged(ByVal Item As XtremePropertyGrid.IPropertyGridItem)

End Sub



Posted By: Boyd
Date Posted: 22 February 2005 at 12:18pm

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:

private void axPropertyGrid_ValueChanged(object sender, AxXtremePropertyGrid._DPropertyGridEvents_ValueChangedEvent e)
{
    Console.WriteLine("Value Changed for " + e.item.Caption);
}



Posted By: bluelizard
Date Posted: 24 March 2005 at 4:14pm
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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net