Print Page | Close Window

Control Button, Property Grid and Focus

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=2008
Printed Date: 17 November 2024 at 4:18pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Control Button, Property Grid and Focus
Posted By: ianp
Subject: Control Button, Property Grid and Focus
Date 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




Replies:
Posted By: Oleg
Date Posted: 25 March 2005 at 2:03am

it is correct. CommandBars don't grab focus

 



-------------
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