DataGridView and ComboBoxes
-
Hello! I have a DataGridView object (not DataGrid) that has three DropDown ComboBoxes (cboOne, cboTwo and cboThree) in columns one,two and three. I need to update contents of cboTwo dynamically depending on the selection in cboOne on the same grid. Then based on selection from cboTwo, cboThree should change it's contents. Please consider that every row could have a different selection for cboOne that would impact available choices for cboTwo that in turn would impact contents of cboThree. I am just wondering if someone can help me out - if at all this is possible. Thank you. CrazyYankee
-
Hello! I have a DataGridView object (not DataGrid) that has three DropDown ComboBoxes (cboOne, cboTwo and cboThree) in columns one,two and three. I need to update contents of cboTwo dynamically depending on the selection in cboOne on the same grid. Then based on selection from cboTwo, cboThree should change it's contents. Please consider that every row could have a different selection for cboOne that would impact available choices for cboTwo that in turn would impact contents of cboThree. I am just wondering if someone can help me out - if at all this is possible. Thank you. CrazyYankee
-
Hello! I have a DataGridView object (not DataGrid) that has three DropDown ComboBoxes (cboOne, cboTwo and cboThree) in columns one,two and three. I need to update contents of cboTwo dynamically depending on the selection in cboOne on the same grid. Then based on selection from cboTwo, cboThree should change it's contents. Please consider that every row could have a different selection for cboOne that would impact available choices for cboTwo that in turn would impact contents of cboThree. I am just wondering if someone can help me out - if at all this is possible. Thank you. CrazyYankee
You can use CellValueChanged event of dataGridView and write some code in this event. i make a sample of code you must know the index of col1 which will effect the values of col2. this code is getting the object of cell1 and remove it from cell2 private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) { object _value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; ((DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[2]).Items.Remove(_value); } } i hope this will help you
mca