Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Property Grid
  New Posts New Posts RSS Feed - PropertyGrid Dirty
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

PropertyGrid Dirty

 Post Reply Post Reply
Author
Message
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Topic: PropertyGrid Dirty
    Posted: 23 March 2008 at 12:12pm
Is there an easy way to programmatically tell any PropertyGrid items have been modified by the user (for example, a Dirty property)?

I've tried comparing the DefaultValue to the Value property, but in the case of Enums, the DefaultValue returns the translated label for the enum, while the Value property returns the actual value of the enum. The other option is to store the original value of each child item and then compare, but this is tedious when you have a long list of items.

If a Dirty property could be added, that would be great. Also of use would be an OriginalValue property for each item.

Thanks.
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 4:44pm
Hi,
 
If you set:  wndPropertyGrid.HighlightChangedItems = True
the changed values will be highlighted
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 5:08pm
Hi Aaron,

Thanks for replying. I have the HighlighChangedItems property set already, I'm trying to determine if anything has changed programatically to decide whether or not to restart my server application. If the user hasn't changed any settings, then I'll just leave everything running as is. I guess I was just hoping that CJ would expose whatever they are using to highlight the changed items as a property for each item so we can test for changes.
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 1:38am
Hi,
 
You could try this:
 
In the ValueChanged event:
 
If CStr(Item.Value) <> CStr(Item.DefaultValue) Then
        Item.ValueMetrics.ForeColor = vbRed 'value changed
Else
        Item.ValueMetrics.ForeColor = vbGreen 'value changed into default value back again
End If
 
 
Iterate through the items:
 
Dim propItem As PropertyGridItem
   
    For Each propItem In wndPropertyGrid.Categories(1).Childs(1).Childs
        Select Case propItem.ValueMetrics.ForeColor
            Case vbRed: MsgBox "Value changed..."
            Case vbGreen: MsgBox "Value changed back to original..."
            Case Else: MsgBox "Value never changed..."
        End Select
    Next propItem
 
Test with checkbox,string and enum, the other items you have to check yourself
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 4:08am
Hi,
 
In the test I used PropertyGridItemString and not PropertyGridItemEnum, I did add some constraints to the PropertyGridItemString. In this case you are able to compare the Item.DefaultValue with the Item.Value  
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2008 at 9:48am
Hi Aaron,

Thanks for your help. I'm not sure that I can get things to work the way that I want with your code when using PropertyGridItemString because the constraints don't seem to work (nor does the drop-down appears).

I have a PropertyGridItem that needs to show Yes/No in a drop-down. Using the PropertyGridItemBoolean would be ideal here, but it only seems to show True/False. So I use a PropertyGridItemEnum and set constraints for 0 = No, -1 = Yes. I've tried using constraints with PropertyGridItemString and PropertyGridItemBool, but they don't seem to do anything for those item types. You mention that you got the PropertyGrid to show constraints for the "string" type...how did you do it? (NOTE: I am now beta testing v12, so maybe it is a problem with the new version?).

In any case, it seems to me that the PropertyGridItemEnum type should return its underlying value for the DefaultValue property and *not* the constraint caption, since that is purely cosmetic. What do you think?



Back to Top
Baldur View Drop Down
Senior Member
Senior Member


Joined: 22 November 2006
Location: Germany
Status: Offline
Points: 244
Post Options Post Options   Thanks (0) Thanks(0)   Quote Baldur Quote  Post ReplyReply Direct Link To This Post Posted: 27 March 2008 at 12:03pm
If you use PropertyGridItemString, you have to add an inplacebutton with Id 101 for dropdownbutton.
In Changing-Event you can check against the constaints and if false set cancel to true.
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 27 March 2008 at 3:15pm
Hi,
 
You don't have to add an inplaceButton just set Item.Flags = ItemHasComboButton.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.