Hello
I need to enable the update button in a form whenever the value of any control in the form change its value. It works fine for RadTextBox, RadComboBox, but it doesn't work either for RadSpinEditor nor RadDateTimePicker.
Private Sub Text_Changed(ByVal sender As System.Object, ByVal e As System.EventArgs) _ |
Handles RadTextBox1.TextChanged, _ |
RadComboBox1.TextChanged, _ |
RadDateTimePicker1.TextChanged, _ |
RadSpinEditor1.TextChanged |
If RadTextBox1.ContainsFocus Or _ |
RadComboBox1.ContainsFocus Or _ |
RadDateTimePicker1.ContainsFocus Or _ |
RadSpinEditor1.ContainsFocus Then |
Me.UpdateButton.Enabled = True |
End If |
End Sub |
I tried a more generic way to do it with this procedure, that didn't work too:
Private Sub Text_Changed(ByVal sender As System.Object, ByVal e As System.EventArgs) _ |
Handles RadTextBox1.TextChanged, _ |
RadComboBox1.TextChanged, _ |
RadDateTimePicker1.TextChanged, _ |
RadSpinEditor1.TextChanged |
If HasFocus(sender) Then |
Me.RadButton1.Enabled = True |
End If |
End Sub |
Public Function HasFocus(ByVal sender As System.Object) As Boolean |
Dim radElemento As Telerik.WinControls.RadElement |
If sender.GetType Is GetType(Telerik.WinControls.UI.RadTextBox) Then |
radElemento = DirectCast(sender, Telerik.WinControls.UI.RadTextBox).FocusedElement |
End If |
If sender.GetType Is GetType(Telerik.WinControls.UI.RadComboBox) Then |
radElemento = DirectCast(sender, Telerik.WinControls.UI.RadComboBox).FocusedElement |
End If |
If sender.GetType Is GetType(Telerik.WinControls.UI.RadSpinEditor) Then |
radElemento = DirectCast(sender, Telerik.WinControls.UI.RadSpinEditor).FocusedElement |
End If |
If sender.GetType Is GetType(Telerik.WinControls.UI.RadDateTimePicker) Then |
radElemento = DirectCast(sender, Telerik.WinControls.UI.RadDateTimePicker).FocusedElement |
End If |
If sender.GetType Is GetType(Telerik.WinControls.UI.RadCheckBox) Then |
radElemento = DirectCast(sender, Telerik.WinControls.UI.RadCheckBox).FocusedElement |
End If |
If Not radElemento Is Nothing AndAlso radElemento.ContainsFocus Then |
Return True |
Else |
Return False |
End If |
End Function |
Thank you