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" Thene.Button.Editor.Value = 0.05End 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 IfNextEnd 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
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
jct said: 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
jct, thanks for the prompt answer.
Mine was just an example with the DirectCast, what I'm really interested in is the RightButton text, so I need the "e"
From your solution, how can I do that?
On the other hand, previously I used Me.UltraTabControl1.Control at no avail...