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

Disable Editing in radcombobox

1 Answer 365 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mateo
Top achievements
Rank 1
Mateo asked on 16 Sep 2009, 06:29 PM

I have a combobox defined like this:

cmbOrigin.Items.Clear();  
cmbOrigin.AutoCompleteMode = AutoCompleteMode.SuggestAppend;  
cmbOrigin.NullText = Transat.PDP.Client.Properties.Resources.ControlDataOriginNullText;  
foreach (MyItem i in ListOfMyItems)  
{  
    cmbOrigin.Items.Add(new RadComboBoxItem(string.Format("{0} - {1}", i.Code, i.Nom), i));  

I want to have the AutoCompleteMode set to SuggestAppend so that the rest of the text get showed and the list is showed too.
What i dont want is the user to be able to type 2 letters and then hit backspace and go out of the combobox leaving me with an inconsistant value.

how can i force the user to pick a valid entry in the combobox?


thanks
mateo

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 23 Sep 2009, 07:14 AM
Hi Mateo,

Thanks for writing and for your question.

First, I would like to apologize for the delay with my answer due to a couple of national holidays here.

Back on your question.

I guess using the KeyDown event of the RadComboBox control and deselecting the input of the user upon clicking on the Backspace key would do the job. Take a look at the code snippet below:

 private void OnRadComboBox_KeyDOwn(object sender, KeyEventArgs e) 
        { 
            if (e.KeyData == Keys.Back) 
            { 
                this.radComboBox1.Select(0, 0); 
            } 
        } 

Basically, this code will deselect any selected text in the RadComboBox control when you click the Backspace key and thus will prevent you from deleting this text. In the case of the SuggestAppend mode, this will leave a valid input in the RadComboBox control as you require.

I hope this is helpful.

You can write back anytime you need further assistance though.

All the best,
Deyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Mateo
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or