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