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

.DefaultValue issues

 Post Reply Post Reply
Author
Message
Josef View Drop Down
Groupie
Groupie


Joined: 15 April 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Josef Quote  Post ReplyReply Direct Link To This Post Topic: .DefaultValue issues
    Posted: 13 October 2008 at 8:35pm
Hello,

.Value = Variant
.Defaultvalue = String

Both properties should contain the same vartype (Variant).

With PropertyItemEnum, DefaultValue contains the text instead of the selected data value. This makes it impossible to compare "if .Value <> .DefaultValue then ...".

Please fix this issues in the next version.
A new property ".ValueChanged" would be nice too.

Thank you,
Josef
Product: Xtreme SuitePro ActiveX v13.2.1
Platform: Windows 2008 (64bit)
Language: Visual Basic 6.0
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: 22 October 2008 at 2:22pm
Hi,
  1. Did you try to compare both values. I don't see what your problem is...
  2. What about ValueChanged event?

  

Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Josef View Drop Down
Groupie
Groupie


Joined: 15 April 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Josef Quote  Post ReplyReply Direct Link To This Post Posted: 23 October 2008 at 6:27pm
Hi Aaron,

the problem is this (on German windows):

Private Sub PropGrid_ValueChanged(ByVal Item As XtremePropertyGrid.IPropertyGridItem)


    ' .AddChildItem(PropertyItemBool, "BoolItem", True)
    Debug.Print Item.Value, Item.DefaultValue
    '           Falsch      True
    '           Wahr        True


    ' With .AddChildItem(PropertyItemEnum, "EnumItem", 10)
    '    .Constraints.Add "TestData 0", 0
    '    .Constraints.Add "TestData 5", 5
    '    .Constraints.Add "TestData 10", 10
    '    .Constraints.Add "TestData 15", 15
    ' End With
    Debug.Print Item.Value, Item.DefaultValue
               '0             TestData 10
               '5             TestData 10
               '10            TestData 10
               '15            TestData 10

    ' In both cases, you can't do this:
    With Item
        If .DefaultValue <> .Value Then
            Me.cmdSave.Enabled = true
        End If
    End With
    
End Sub

Hope you can see the problem now.

Thank you,
Josef
Product: Xtreme SuitePro ActiveX v13.2.1
Platform: Windows 2008 (64bit)
Language: Visual Basic 6.0
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 October 2008 at 2:23am
Hi,
 
In someway your code doesn't work and that is strange??? You would expect that it would work.
 
I tried it with your code and failed, but you can do it like this:
 
cmdSave.Enabled = IIf((Item.Value <> Item.DefaultValue), True, False)
 
This will work  and that's why I wondered why you said you couldn't compare both values.
 
 
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Josef View Drop Down
Groupie
Groupie


Joined: 15 April 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Josef Quote  Post ReplyReply Direct Link To This Post Posted: 24 October 2008 at 6:21pm
Hello Aaron,

Of course it is strange, if my code does not work !

My code would work, if this description of Defaultvalue in SymbolReference.chm would be true:

"The DefaultValue is the value provided when the item was added with the AddChildItem method."

This is not true, because the value added with AddChildItem is a variant datatype, but Defaultvalue is string.

BTW: Your code snippet would have the same problem as my sample code
To make it work, you have to convert .Defaultvalue to Variant:
cmdSave.Enabled = (Item.Value <> CBool(Item.DefaultValue))
But this is only valid, if Item.Type = PropertyItemBool.
So you have to write different code for each ItemType, instead of just using
If .DefaultValue <> .Value Then
for all items.

Please try this real life sample (I think it addresses the same problem):
With .AddChildItem(PropertyItemEnum, "Default Addresslist", 5)

    .Constraints.Add "AddressBook1", 0
    .Constraints.Add " All Users", 5
    .Constraints.Add " Public Folders", 10
    .Constraints.Add "AddressBook2", 15
    .Constraints.Add " All Users", 20
    .Constraints.Add " Public Folders", 25
    .Constraints.Add "AddressBook3", 30
    .Constraints.Add " All Users", 35
    .Constraints.Add " Public Folders", 40
End With

1. Although the value added with AddChildItem is 5, the preselected Combobox-Item is the third " All Users" item (35).

2. How would you set cmdSave.Enabled in ValueChanged event, if user selects another " All Users" item? Defaultvalue contains string " All Users" instead of variant 5.

Please think about this issue again, hope I can change your mind.

Thank you,
Josef

Product: Xtreme SuitePro ActiveX v13.2.1
Platform: Windows 2008 (64bit)
Language: Visual Basic 6.0
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: 26 October 2008 at 4:42am
Hi,
 
OK, now I know what you mean. Return values of items in ValueChanged event always return string and not the type as assigned to it. I tested your issue with PropertyItemString and it worked, but after testing with different types I have to say this doesn't work at all. Most types will work when comparing the Item.Value with Item.DefaultValue, but most isn't good enough
 
  1. Enum: returns value selected index of constraint instead of caption
  2. Bool: returns value True,False instead of "True","False"
  3. Color: returns a right value but only when assigning the DefaultValue yourself you can compare both values.
  4. Font: Fontname is working but changing size or other properties isn't

Note: I didn't test PropertyItemOption and PropertyItemEnumFlags

Conlusion: You have to put a lot of effort into it to compare Value and DefaultValue to make it right.
 
My advice would be adding a property ValueChanged (Read/Write) for propertygrid items, in this case we would only have to check this property and not a lot of coding just to compare both values. There's a property HighlightChangedItems so PropertyGrid control already knows the Item.Value has been changed. So it wouldn't be hard to implement this feature  
 
 
Thanks a lot
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Josef View Drop Down
Groupie
Groupie


Joined: 15 April 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Josef Quote  Post ReplyReply Direct Link To This Post Posted: 26 October 2008 at 11:57am
Aaron,

Thank you for testing. A new event would help a little, but does not solve the whole problem:

In the Save-code of an option dialog, you will have the same problem: To know which item was changed by enumerating all items.

But again, you can't do this without writing code for each itemtype. A property .ValueChanged would help, but the best solution would be if .Defaultvalue and .Value containts the same variable type (Variant) and .Defaultvalue contains the value added by .AddChildItem and nothing else.

Currently I'm using the .Tag (=variant type) property to store the Defaultvalue and compare .Tag with .Value to see if the item was changed. But in fact, this would not be necessary if DefaultValue would work as described in helpfile.

Thank you,
Josef
Product: Xtreme SuitePro ActiveX v13.2.1
Platform: Windows 2008 (64bit)
Language: Visual Basic 6.0
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: 26 October 2008 at 1:52pm
Hi,
 
If CJ would add ValueChanged property for PropertyGridItem and Item.Value would be changed (new) ValueChanged property flag would be true and we don't have to compare the values anymore. I think this would be better than changing return values (think about previous versions in which other users have build their "workarounds" to get this working like you now  ) 
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
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: 22 November 2008 at 5:04am
Hi,
 
CJ could make HighlightChangedItem public and we could use this to check if the value has been changed
 
Thanks in advance
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
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: 28 December 2008 at 5:25am
Originally posted by Aaron Aaron wrote:

Hi,
 
CJ could make HighlightChangedItem public and we could use this to check if the value has been changed
 
Thanks in advance
 
 
 
Oleg??? Could this be possible in next releases?
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 29 December 2008 at 3:31am
Added to my TODO list. :)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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: 19 May 2009 at 2:51pm
Hi Oleg,
 
Is this option removed from TODO list and added to Beta release?
I really hope so because I'm really desperate...
 
Thanks a lot in advance
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
sforces View Drop Down
Groupie
Groupie


Joined: 13 May 2009
Status: Offline
Points: 71
Post Options Post Options   Thanks (0) Thanks(0)   Quote sforces Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 2009 at 2:21am
I third this request.

I'm converting to CJ PropertyList from another PropertyList and am finding this would RRRREEEALLLY make things a whole lot simpler as Araron and Josef have already pointed out.

It's been 5 months since your last response. Can you please update on when this will be included?

Originally posted by Aaron Aaron wrote:

Hi Oleg,
 
Is this option removed from TODO list and added to Beta release?
I really hope so because I'm really desperate...
 
Thanks a lot in advance
 
Back to Top
Josef View Drop Down
Groupie
Groupie


Joined: 15 April 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Josef Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2009 at 5:16pm
Hello CJ-Team,

I'm really impressed that you were not able to change the type of .DefaultValue from String to Variant within the last year .

You did this change on ListBox/ComboBox .ItemData method in 13.2, why not on PropertyGrid.DefaultValue??

Bye, Josef
Product: Xtreme SuitePro ActiveX v13.2.1
Platform: Windows 2008 (64bit)
Language: Visual Basic 6.0
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.234 seconds.