This is a migrated thread and some comments may be shown as answers.

Nullable TextBox bound to numeric column

3 Answers 158 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Piotr
Top achievements
Rank 1
Piotr asked on 18 May 2011, 03:16 PM
Hi,

I have a RadMaskedEditBox bound to BindingSource which is connected to some column with numeric (Int32) in DataTable in some DataSource.
Values are properly displayed in the control, but I want users to be able to nullify the column value in the table
by deleting existing value from the RadMaskedEditBox and leaving it empty.
Is there any way of configuring RadMaskedEditBox to achieve this? Or maybe some other control is better for the job?
This feature does not exist in standard WinForms TextBox and I am currently searching for the controls that would do that task without any tweaking etc.

Thanks,
Piotr

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 23 May 2011, 09:32 PM
Hi Piotr,

Thank you for the question.

Our current implementation of RadMaskedEditBox does not support null values and cannot be used in this scenario. However, this is a nice feature and I added it in our feature requests list. We will consider it when implementing the next version of this control.

If you have any additional questions, do not hesitate to ask.

Best wishes, Peter
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Jan
Top achievements
Rank 1
answered on 06 Mar 2013, 02:32 PM
Hi

I need this same kind of behavior for my maskededitbox.
I want the user to be able to enter a number in "n2" numeric format but wish to allow the user to clear the field, setting the bound property to null.

Is there any change in this or is this still impossible?

Thanks,

Jan
0
Peter
Telerik team
answered on 07 Mar 2013, 04:36 PM
Hello Jan,

Thank you for writing:

The numeric masks does not provide a support for nullable values. However, you can try to achieve the requested behavior by setting 
explicitly the Value of the MaskedEditBox to Null. For example you can add next to the MaskedEditBox a button that clears the value:
Private Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
    Me.RadMaskedEditBox1.Value = Nothing
End Sub

Or you can handle the KeyDown event and if the key is the Delete key and the user selected the whole text in the editor to set the Value to null:
Sub key_Down(s As Object, e As KeyEventArgs) Handles RadMaskedEditBox1.KeyDown
    If e.KeyCode = Keys.Delete Then
        If Me.RadMaskedEditBox1.SelectionLength = Me.RadMaskedEditBox1.Text.Length Then 'the all text is selected and press del
            Me.RadMaskedEditBox1.Value = Nothing
        End If
    End If
End Sub

Please bear in mind that the Numeric masks are not designed and tested to work with NULL values and we do not guarantee that they will work correctly in all possible cases - for example this will not work if the user deletes the text with the Backspace button or when the user presses the Delete button without selecting the whole text.

Please, refer to the attached project.

I hope this helps.

Kind regards,
Peter
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Tags
TextBox
Asked by
Piotr
Top achievements
Rank 1
Answers by
Peter
Telerik team
Jan
Top achievements
Rank 1
Share this question
or