Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
710
NumericEditor - arrays - events
posted

Hi everyone!

Here is my request for help. I have several UltraNumericEditors on the same form and I want to change the same property once I click on one of the RigthButton, for ALL the NumericEditors.

So far I've tried the following code, and no luck! It only works with the caller...

Private Sub MV_EditorButtonClick(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinEditors.EditorButtonEventArgs) Handles UltraNumericEditor_MV_1.EditorButtonClick, UltraNumericEditor_MV_2.EditorButtonClick

If e.Button.Key = "Def" Then
e.Button.Editor.Value = 0.05
End If

Dim stateButton As EditorButton = CType(e.Button, EditorButton)

For Each ctrl As Control In Me.Controls
 If TypeOf (ctrl) Is UltraNumericEditor Then
 DirectCast(sender, UltraNumericEditor).BackColor = Color.Wheat
  Select Case stateButton.Text
   Case "Meters"
    stateButton.Text = "Feet"
   Case "Feet"
    stateButton.Text = "Inches"
   Case "Inches"
    stateButton.Text = "Meters"
  End Select
 Else
  DirectCast(sender, UltraNumericEditor).BackColor = Color.CadetBlue
 End If
Next
End Sub

 

1) The code above won't work "as is" unless I replace "ctrl" with "sender" (???), I mean Typeof Ctrl does not recognize the UltraNumericEditor type.
2) If I use "sender", then it works, but only changes the properties of the NumericEditor that was selected

What am I doing wrong?

In short, what I want is to click on the RighButton of one of the NumericEditors and change the text to ALL at once.

Thanks in advance!

Gus

Parents
No Data
Reply
  • 17259
    Offline posted

    If you change ctrl to sender, then the condition is always true, since sender is the control that was clicked.

    You problem is that Me.Controls is only the top level controls and probably your UltraNumericEditors are in a tab page or a panel.

    You need to create a recursive method like this and call it from your event:

    public sub ChangeValue(control as Control)

    If TypeOf(control) Is UltraNumericEditor Then

    DirectCast....

    End If

    For Each child As Control In control.Controls

    ChangeValue(child)

    Next

    End Sub

Children