Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Control Button, Property Grid and Focus
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Control Button, Property Grid and Focus

 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: Control Button, Property Grid and Focus
    Posted: 22 March 2005 at 10:11am

When a user types a value into a property grid item, then clicks a control on a commandbar, the propertygrid item value is not updated before the execute event fires. This results in the control returning the old (non visible) value when the PropertyGridItem.Value is accessed.

However, if the PropertyGridItem.Value is accessed by clicking a command button on the same form, the visible value is returned.

It seems that the value is only updated when the focus changes from the grid item (as in the case of the command button) and the Commandbar control does not move the focus from the property grid when the execute event fires.

Is this expected behaviour, or a bug?

The following code recreates my 'problem'


Private Sub Form_Load()
  ' Add read button
  With Me.CommandBars
    .ActiveMenuBar.Controls.Add xtpControlButton, 2, "Read"
    .KeyBindings.Add 1, 13, 2
  End With
  ' Add property grid items
  With Me.PropertyGrid
    .AddCategory "Criteria"
    .Categories(1).Expanded = True
    .Categories(1).AddChildItem PropertyItemString, "Test"
    .Categories(1).AddChildItem PropertyItemNumber, "Test1"
    .Categories(1).AddChildItem PropertyItemEnum, "Test2"
    .Categories(1).Childs(3).Constraints.Add "enum 1", 1
    .Categories(1).Childs(3).Constraints.Add "enum 2", 2
  End With
End Sub
Private Sub CommandBars_Execute(ByVal Control As XtremeCommandBars.ICommandBarControl)
  If Control.Id = 2 Then
  ' UNCOMMENT THE FOLLOWING LINE TO ENSURE VISIBLE VALUES ARE READ
  '  Me.SetFocus
    ReadValues
  End If
End Sub
Private Sub Command1_Click()
  ReadValues
End Sub
Private Sub ReadValues()
  For Each child In Me.PropertyGrid.Categories(1).Childs
    s = s & vbNewLine & child.Caption & ": " & child.Value
  Next
  MsgBox s
End Sub

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: 25 March 2005 at 2:03am

it is correct. CommandBars don't grab focus

 

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.141 seconds.