问题
I truly do hate to ask such a crayon-question... I'm trying to clear, not remove a drop down combo list in VSC#. My ddl lets the user choose the payRate of an employee. I've researched everywhere, even here, and everything suggests using..
cmboPayRate.Items.Clear(); .. or
cmboPayRate.SelectedIndex = - 1;
I even threw in
cmboPayRate.SelectedItem = -1;
for safe measure. Nothing working. Again, I know this is easy(should be), but not working for me. Any suggestions would be greatly appreciated.
Thanks -Matt.
回答1:
try
DropDownList1.Items.Clear();
No hidden and clear the Drop Down List.
回答2:
you can do as below
while(cmboPayRate.Items.Count>0)
cmboPayRate.Items.RemoveAt(0);
来源:https://stackoverflow.com/questions/17519278/clearing-a-drop-down-list-in-c-sharp