I have a class derived from DataSet that I'm using as a datasource. My DataGridView has 8 columns of which 3 are multiple value choices that are edited with drop down combo boxes.
If I let the Datasource generate the columns for the DataGridView, then all of the column types are DataGridViewTextBoxColumn. However the DataGridView is populated with my original row values.
If I set AutoGenerateColumns to false and add my own column types to the DataGridView I can add DataGridViewComboBoxColumn for the 3 columns that require it. However, the DataSource, while it contains the row data, does not populate the rows of my DataGridView.
Obviously I want both things to happen. The rows need to be populated from the DataSource and the column need to be correctly editable from the DataGridView as DataGridViewComboBoxColumns. Why can't I have both? What am I doing wrong.
Please note this is not a question about using a DataSource to populate the items in a ComboBox.
code fragment
alarmDataSet = new AlarmDataSet(sAlarms);
gridView.AutoGenerateColumns = false;
gridView.DataSource = alarmDataSet;
gridView.DataMember = sAlarms;
another code fragment
cm = new DataGridViewComboBoxColumn();
cm.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
cm.HeaderText = ci.Name;
cm.Name = ci.DataName;
cm.MaxDropDownItems = 3;
cm.Items.Add("Once");
cm.Items.Add("Repeat");
cm.Items.Add("Off");
gridView.Columns.Add(cm);
Thanks
DataPropertyName
of theDataGridViewComboBoxColumn
- This should be set to the column in the source datatable to allow it to map to a value in drop down – JayV