Hi,
I have written windows application
My requirement is I have to enter only digits in DropdownList, for this I have writter code as following
private void BranchCodeRadDropDownList_KeyPress(object sender, KeyPressEventArgs e)
{
BranchCodeRadDropDownList.DropDownStyle = RadDropDownStyle.DropDown;
BranchCodeRadDropDownList.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
Regex regex = new Regex("^[0-9\b]*$");
e.Handled= (!regex.IsMatch(e.KeyChar.ToString())); }
How to write code for enter only digits in dropdownlist ?
How to write code for enter only digits in dropdownlist ?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 11, 2011, 4:37 AM EDT
Simply add this in KeyPress event.
if ((!char.IsDigit(e.KeyChar)) && (e.KeyChar != 8))
Sam HobbsRank #107 · 20.5K reputationPosted Oct 11, 2011, 9:03 AM EDT