Print Page | Close Window

[SOLVED] PropertyEnumItem index?

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=17758
Printed Date: 17 December 2024 at 9:07pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED] PropertyEnumItem index?
Posted By: rdeboer
Subject: [SOLVED] PropertyEnumItem index?
Date 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



Replies:
Posted By: Oleg
Date Posted: 06 January 2011 at 4:29pm
Same  ItemEnum.Value will work later.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: rdeboer
Date 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


Posted By: Aaron
Date 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....


Posted By: rdeboer
Date 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



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