Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when I used databound for get the value from database, how can I hide or (make some items invisable) from this combo.
when I tried to delete some items the following error occur
Items collection cannot be modified when the DataSource property is set.
best regards
Posted

first make a DataTable from current ComboBox DataSource:

DataTable dt =(DataTable) comboBox1.DataSource;


then find target item in DT and remove it from DT.
then set again DT for comboBox datasourse:

  DataTable dt = (DataTable)comboBox1.DataSource;
           
DataRow dr = dt.Rows.Find("TargetKey");
dt.Rows.Remove(dr);
           
comboBox1.DataSource = dt;
 
Share this answer
 
Hello somur-ruteeb,

Try out this..

Instead of binding the the collection to the combobox datasource you've added items to combobox.Itemscollection for each row. This way we can have different values for each row in the combobox.

Thanks

Renish
 
Share this answer
 
v2
Comments
somur-ruteeb 10-Aug-13 7:32am    
but in this case how can I save the (selectedvalue)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900