Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Property Grid
  New Posts New Posts RSS Feed - [SOLVED] PropertyEnumItem index?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED] PropertyEnumItem index?

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


Joined: 29 April 2004
Location: Netherlands
Status: Offline
Points: 81
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdeboer Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED] PropertyEnumItem index?
    Posted: 06 January 2011 at 4:16pm
I use code similar like this:

    Dim ItemEnum As PropertyGridItem
    
    'Adds a PropertyItemEnum item with a caption of "Enum" and an initial value of 2
    'This will cause the constraint with a value of 2 to be selected
    Set ItemEnum = Category.AddChildItem(PropertyItemEnum, "Enum", 2)
    
    'Adds some constraints along with a Data value
    ItemEnum.Constraints.Add "Windows 98", 1
    ItemEnum.Constraints.Add "Windows 2000", 2
    ItemEnum.Constraints.Add "Windows XP", 3

Now while ItemEnum is active, you can read the value of the selected item:

Debug.Print "Enum Item Value =" & ItemEnum.Value

So far so good. But how do i find this value later in the program?

The old VB method would be:

Value = cmbBox.ListIndex

to find the listindex of the currently selected item.

How do i find 'ListIndex' in PropertyGrid? lets say i selected Windows 2000, the listindex would be 2.




Product: Xtreme Suite Pro (ActiveX) version 11
Platform: Windows XP SP3 (32bit)
Language: Visual Basic 6.0 SP6
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: 06 January 2011 at 4:29pm
Same  ItemEnum.Value will work later.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
rdeboer View Drop Down
Groupie
Groupie


Joined: 29 April 2004
Location: Netherlands
Status: Offline
Points: 81
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdeboer Quote  Post ReplyReply Direct Link To This Post Posted: 06 January 2011 at 5:06pm
How? I tried:

Set Itemx = AdvancedGrid.FindItem("Enum")
If Not (Itemx Is Nothing) Then
    Debug.Print Itemx.Constraints(Itemx.Value)
End If

But that gives an error?

Excuse my stupidity :)


Product: Xtreme Suite Pro (ActiveX) version 11
Platform: Windows XP SP3 (32bit)
Language: Visual Basic 6.0 SP6
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: 07 January 2011 at 1:36am

Hi,

Your stupidity is forgiven Wink

Constraints collection isn't zero based, first item will start at 1 Confused
So if you would add constraint:
  • .Constraints. Add "First item", 0
  • .Constraints. Add "Second item", 1
  • .Constraints. Add "Third item", 2
and want to get the index of the first item, it will produce an error because there is no constraint with index 0  
In this case you have to set Item.value + 1
  • Me.wndPropertyGrid.FindItem(ITEM.ID or "Caption").Constraints(Me.wndPropertyGrid.FindItem(ITEM.ID or "Caption").Value + 1).Data (or index)
If you don't use successive numbers for the <Data> for the added constraints above doesn't work
  • .Constraints. Add "First item", 0
  • .Constraints. Add "Second item", 1
  • .Constraints. Add "Third item", 2
  • .Constraints. Add "Third item", 4
  • .Constraints. Add "Third item", 8

In this case you have to loop constraints and compare constraint, annoying thing to do (in my opinion...)

 
Best way is to start added constraint with <Data> = 1 and use successive numbers, this way you are able to use Item.Value to "find" selected constraint.
 
Hope this helps Wink
 
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
rdeboer View Drop Down
Groupie
Groupie


Joined: 29 April 2004
Location: Netherlands
Status: Offline
Points: 81
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdeboer Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2011 at 10:33am
Thank you again, Aaron! 

Smile
Product: Xtreme Suite Pro (ActiveX) version 11
Platform: Windows XP SP3 (32bit)
Language: Visual Basic 6.0 SP6
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.191 seconds.