Assign value to DataGridViewComboBoxCell at run-time
-
Dear Friends I've bound the DataGridViewComboBoxColumn to a table in Database, and I want programmatically to change the index of the selected item in the DataGridViewComboBoxCell, and I didn't find any property to do that kindly help me to do this...
-
Dear Friends I've bound the DataGridViewComboBoxColumn to a table in Database, and I want programmatically to change the index of the selected item in the DataGridViewComboBoxCell, and I didn't find any property to do that kindly help me to do this...
Hello Your title was about assigning values. This means True or false valus to the cells. This is done simply by changing the
DataGridViewCheckBoxCell.Value
property to either true or false. OTOH in your post you said you want to change the index!! this is considered more with rows not columns. If you want to change the display index of a row -Move it up or down in the grid-:DataGridViewRow MyTempRow = MyDataGridView.Rows[OldIndex];
MyDataGridView.Rows.RemoveAt(OldIndex); //Keeps it alive till you reinsert it
MyDataGridView.Rows.Insert(NewIndex, MyTempRow);PS.I used OldIndex/NewIndex naming conventions just for the sake of clarity. If you want to get the first selected row use MyDataGridView.SelectedRows[0], provided that you check it is not null first.
Regards:rose: