Print Page | Close Window

Constraint 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=969
Printed Date: 22 November 2024 at 4:56am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Constraint Index
Posted By: ianp
Subject: Constraint Index
Date Posted: 22 July 2004 at 5:10am

Currently I am creating a constrained item from a adodb recordset which contains a primary key field and a descriptive text field. I would like the user to select a value for the property using the descriptive text field, but use the primary key in my code.

Using a standard VB.ComboBox, I would add an item using the descriptive field in the recordset and then set the ItemData using the Primary Key field.

However, with the PropertyGrid I need to work around the fact that an item constraint only has an Index and Caption property, it does not have an "ItemData" property.

Here's what I'm doing (I've taken the recordset out of the code for simplicity):

Option Explicit
Dim m_OS() As Long

Private Sub Form_Load()
Dim pgC As XtremePropertyGrid.PropertyGridItem
Dim pgI As XtremePropertyGrid.PropertyGridItem
  With Me.PropertyGrid1
    Set pgC = .AddCategory("test")
    pgC.Expanded = True
    Set pgI = pgC.AddChildItem(PropertyItemString, "prop", "1")
    Set pgI = Nothing
    Set pgI = pgC.AddChildItem(PropertyItemString, "Operating System", Null)
    pgI.ConstraintEdit = True
    pgI.Flags = ItemHasComboButton
    ' would usually be loaded from an adodb.recordset
    ReDim m_OS(3) As Long
    pgI.Constraints.Add "Windows XP": m_OS(1) = 3
    pgI.Constraints.Add "Windows 2000": m_OS(2) = 1
    pgI.Constraints.Add "Windows 98": m_OS(3) = 2
  End With
End Sub

Private Sub PropertyGrid1_ValueChanged(ByVal Item As XtremePropertyGrid.IPropertyGridItem)
Dim i As Long
  If Item.Caption = "Operating System" Then
    For i = 1 To Item.Constraints.Count
      If Item.Constraints(i) = Item.Value Then MsgBox "Constraint Index is " & i & vbCrLf & "Contraint Key is " & m_OS(i): Exit For
    Next
  End If
End Sub

Is there any way of, at the very least, exposing the index for the constraint selected e.g.

Item.Constraints("Windows 2000").Index        ' --> which would return 2

or, ideally, adding an ItemData (and/or Key) to the constraint? e.g.
' Add Constraints:
Item.Constraints.Add "Windows XP", 3
Item.Constraints.Add "Windows 2000", 1
Item.Constraints.Add "Windows 98", 2
' Read Constraints:
Item.Constraints("Windows 2000").Index        ' --> which would return 2
Item.Constraints("Windows 2000").ItemData    ' --> which would return 1
Item.Constraints(2).Caption      ' --> which would return "Windows 2000"
Item.Constraints(2).ItemData    ' --> which would return 1

Better yet, be able to access an items selected constraint directly from the item e.g.

Item.SelectedConstraint.Index   ' --> which would return 2
Item.SelectedConstraint.ItemData   ' --> which would return 1





Replies:
Posted By: ianp
Date Posted: 23 July 2004 at 3:38am

I've just read the version 9.0 release notes and this functionality is (partially?) included in the MFC version

Quote ...
3. CXTPItemConstraints::GetCurrent returned
4.CXTPPropertyGridItem::SetitemData/CXTPPropertyGridItem::Ge tItemData added
...
 
What are the chances of having these in the next ActiveX version?
 
 


Posted By: ianp
Date Posted: 20 October 2004 at 10:56am
Any chance this can be implemented soon?


Posted By: SuperMario
Date Posted: 23 February 2005 at 1:04pm
This functionality is now included (Version 9.60) 


Posted By: ianp
Date Posted: 24 February 2005 at 1:51am

thanks supermario

is the item.selectedconstraint property included? I couldn't see it...



Posted By: Oleg
Date Posted: 24 February 2005 at 4:30am
Use PropertyItemEnum type (see sample)

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



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