0

Is there any way i can prevent any inputs in the field in RadCheckedDropDownList object? I want to let the user check the items he wants but he must not have any acces to write in the field.

OR

Is there a way to check if what he types in the field exists in the Items and if do, select the first item he finds when control lose focus or delete if no item is found?

Silviu
  • 56
  • 7
  • Possible duplicate of [Readonly ComboBox in WinForms](https://stackoverflow.com/questions/162936/readonly-combobox-in-winforms) – Mong Zhu Feb 07 '19 at 12:31
  • have a look at all of the answers of the presumed duplicate – Mong Zhu Feb 07 '19 at 12:31
  • I will go for a [MCVE], a spimple one with 3 item. Because my reaction vary from no reproduction as auto complete as an allow custom text option . It's in the demo https://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx – xdtTransform Feb 07 '19 at 12:35
  • `RadComboBox1.AllowCustomText= false; RadComboBox1.MarkFirstMatch=true;` , https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/how-to/ensure-the-selection-of-existing-items-with-allowcustomtext- – xdtTransform Feb 07 '19 at 12:36
  • By default the user can not type in the field.. If you enable checkbox `CheckBoxes="true"` aspx property of the `telerik:RadComboBox`. – xdtTransform Feb 07 '19 at 12:40
  • Thank you! Yes, it would have been a good idea to use a RadComboBox, but this control is now used in a lot of places and i can't replace the control. But for sure i will take now for next time. – Silviu Feb 07 '19 at 12:44
  • My bad i was on the Ajax conterpart of telerik. things a name differently. It's for Winform.. Wrong documentation. Let me Crtl F. – xdtTransform Feb 07 '19 at 12:48
  • In winform you should not be able to add free text as the `TokenValidating` will be false for non existing element. It should not be possible as proof here is the documentation asking about enabeling free text in `RadCheckedDropDownList`. [doc](https://docs.telerik.com/devtools/winforms/controls/dropdown-listcontrol-and-checkeddropdownlist/checkeddropdownlist/how-to/add-non-existing-items). – xdtTransform Feb 07 '19 at 12:51
  • I will recommend adding an [MCVE] as what you want is the default behavior. A simple form with one button, dropdown, label, 3 item in the loading and `onclick` `label.text = string.Join(", ", dropdown.checkedItems.Select(x=>x.Value))`. – xdtTransform Feb 07 '19 at 13:00

1 Answers1

0

I used the explanation from this and it fixed my problem: https://www.telerik.com/forums/radcheckeddropdownlist-textbox-content

private void radCheckedDropDownList1_LostFocus(object sender, EventArgs e)
{
     string delimiter = this.radCheckedDropDownList1.CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.Delimiter;
     StringBuilder sb = new StringBuilder();
     foreach (RadListDataItem item in this.radCheckedDropDownList1.CheckedItems)
     {
         sb.Append(item.Text + delimiter);
     }
     this.radCheckedDropDownList1.Text = sb.ToString();                              
}
Silviu
  • 56
  • 7