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

Constraint Index

 Post Reply Post Reply
Author
Message
ianp View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 19 December 2003
Location: United Kingdom
Status: Offline
Points: 119
Post Options Post Options   Thanks (0) Thanks(0)   Quote ianp Quote  Post ReplyReply Direct Link To This Post Topic: Constraint Index
    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


Back to Top
ianp View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 19 December 2003
Location: United Kingdom
Status: Offline
Points: 119
Post Options Post Options   Thanks (0) Thanks(0)   Quote ianp Quote  Post ReplyReply Direct Link To This Post 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?
 
 
Back to Top
ianp View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 19 December 2003
Location: United Kingdom
Status: Offline
Points: 119
Post Options Post Options   Thanks (0) Thanks(0)   Quote ianp Quote  Post ReplyReply Direct Link To This Post Posted: 20 October 2004 at 10:56am
Any chance this can be implemented soon?
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2005 at 1:04pm
This functionality is now included (Version 9.60) 
Back to Top
ianp View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 19 December 2003
Location: United Kingdom
Status: Offline
Points: 119
Post Options Post Options   Thanks (0) Thanks(0)   Quote ianp Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2005 at 1:51am

thanks supermario

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

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: 24 February 2005 at 4:30am
Use PropertyItemEnum type (see sample)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.