Saturday, April 07, 2012 4:20 AM
i am using combobox inside datagridview .the combobox is bound to the database and if
the user selects the same item in more than one cell than i want to display a message it's
repitius. i have tried this code to remove the selected item from the combobox.
/foreach (int selectedindex in combobox2.SelectedIndex.ToString())
but it will display the error lik:you can't change the itemcollection property.i thought the error is
due to the combobox bound to the database.
if anyone have idea about how to display the message help me.
thanks in advance
Saturday, April 07, 2012 6:20 AMSo you have populated all comboBoxCells with the same items? And if some item is selected in one cell, this same item cannot be selected in another cell. Am I right?
Saturday, April 07, 2012 8:56 AM
mr mitja .i created a combobox seperately and add it to the gridview and bind the combobox
using database within the datagridview. here is my code:
public ComboBox combobox2 = new ComboBox();
Monday, April 09, 2012 2:14 AMModeratorHi prabhakar78,
According to your title and your description, it seems that you are trying to display a message when the user selects a same item. However, it seems that you want to remove the selected item according to the code. Could you please clarify your requirement?
According to your last reply, you use ComboBox rather than DataGridViewComboBoxCell in DataGridView, so what do you mean by “if the user selects the same item in more than one cell”?
Anyway, if you want to remove the selected item, you can create a new underlying data source, copy each item to it except the selected items and binding to the next Combo Box.
If you still have any doubt and concern about this issue, please let us know. If I misunderstood you, please kindly elaborate your question.
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Bob Wu-MTMicrosoft Contingent Staff, Moderator Monday, April 30, 2012 2:59 AM