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
Mike Saltzman"] Oh, sorry. The problem is that the ButtonsRight collection returns an EditorButtonBase and not all editor buttons have a text property. So you have to cast it to the appropriate type of button. So to break up the code more neatly, it looks like this: Dim une As UltraNumericEditor = DirectCast(sender, UltraNumericEditor) une.BackColor = Color.Wheat Dim eb As EditorButton = DirectCast(une.ButtonsRight("def"), EditorButton) eb.Text = "Text"
Oh, sorry. The problem is that the ButtonsRight collection returns an EditorButtonBase and not all editor buttons have a text property. So you have to cast it to the appropriate type of button.
So to break up the code more neatly, it looks like this:
Dim une As UltraNumericEditor = DirectCast(sender, UltraNumericEditor) une.BackColor = Color.Wheat Dim eb As EditorButton = DirectCast(une.ButtonsRight("def"), EditorButton) eb.Text = "Text"
Mike,
It works perfectly well.
Thanks again for a great service!
Mike Saltzman"] (DirectCast(ctrl, UltraNumericEditor)).ButtonsRight("Def").Text = "text"
(DirectCast(ctrl, UltraNumericEditor)).ButtonsRight("Def").Text = "text"
Thanks for the reply, however something is wrong in that expression.
I pasted the code and syntar error message poped-up
To be honest, I cannot find where the error is.
Additonal help would be greatly appreciated!
Thanks!
I've been able to perform the backcolor change in ALL NumericEditors
However I cannot change the TEXT property of the RightButton...in ALL editors! (works only for the pressed one) Dim stateButton As EditorButton = CType(e.Button, EditorButton)
For Each ctrl As Control In Me.UltraTabPageControl1.Controls If TypeOf (ctrl) Is UltraNumericEditor Then 'And ctrl.HasChildren Then DirectCast(ctrl, UltraNumericEditor).BackColor = Color.CadetBlue Select Case stateButton.Text Case "Meters/Sec" stateButton.Text = "Feet/Sec" Case "Feet/Sec" stateButton.Text = "Inches/Sec" Case "Inches/Sec" stateButton.Text = "Meters/Sec" End Select End If
Moreover, I cannot find the TEXT property! I mean I can find every other one but this.
UltraNumericEditor_MV_1.ButtonsRight.Item("Units").text = "dd" (this is of course what I expect, but doesn't work at all)
Any ideas?