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

SpinEditor - Null Text

1 Answer 139 Views
SpinEditor
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 28 Feb 2013, 07:01 PM
Is there a way to clear the value in a SpinEditor?  I want to be able to press the delete key and clear the value from the textbox and also programmatically clear it.  Something like what you showed me for a DateTimePicker:

dtpFilter1.NullableValue = null;
dtpFilter1.NullDate = System.Convert.ToDateTime("01/01/0001");
dtpFilter1.NullText = "";
  
//and 
  
dtpFilter1.SetToNullValue();


Thank you,
Gary

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Mar 2013, 03:49 PM
Hi Gary,

Thank you for the question.

You should handle the KeyDownEvent and clear the text from the hosted TextBoxItem. 
Please, refer to the code below:
private void Form1_Load(object sender, EventArgs e)
{
    this.radSpinEditor1.SpinElement.TextBoxItem.NullText = "NULL TEXT";
    this.radSpinEditor1.KeyDown += new KeyEventHandler(radSpinEditor1_KeyDown);
}
 
void radSpinEditor1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyData == Keys.Delete)
    {
        this.radSpinEditor1.SpinElement.TextBoxControl.Text = "";
    }
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    this.radSpinEditor1.SpinElement.TextBoxControl.Text = "";
}

Bear in mind that the control will display the Null Text only if it does not contain focus.

I hope this helps. Regards,
Peter
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

Interested, but can’t attend? Register anyway and we’ll send you the recording.
Tags
SpinEditor
Asked by
Doug
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or