I have a datagridview on my form. I am trying to make one of the columns into a ComboBox. I want to initialize the combobox when the form loads (or in designer mode....however, when I add items to the columns "Data" "Items" - the items are gone when I open it back up again).
Here is my code from the designer for the form (relating to datagrid)
//
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewComboBoxColumn1 = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
//
// cardFileDataGridView
//
this.cardFileDataGridView.AutoGenerateColumns = false;
this.cardFileDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.cardFileDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[]
{
this.dataGridViewTextBoxColumn1,
this.dataGridViewComboBoxColumn1,
this.dataGridViewTextBoxColumn4,
this.dataGridViewTextBoxColumn6,
this.dataGridViewTextBoxColumn7,
this.dataGridViewTextBoxColumn8});
this.cardFileDataGridView.DataSource = this.dataTable1BindingSource;
this.cardFileDataGridView.Location = new System.Drawing.Point(24, 82);
this.cardFileDataGridView.Name = "cardFileDataGridView";
this.cardFileDataGridView.Size = new System.Drawing.Size(853, 220);
this.cardFileDataGridView.TabIndex = 15;
in the Page Load event
private
void SearchCardFile_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'shelterValleyCombined.DataTable1' table. You can move, or remove it, as needed.
this.dataTable1TableAdapter.FillCombined(this.shelterValleyCombined.DataTable1);
//
var comboColumn = this.cardFileDataGridView.Columns["Status"] as DataGridViewComboBoxColumn;
comboColumn.Items.Add(
"Shelter Valley Inventory");
}
The datagridview is databound to a SQLExpress Database Table using dataset.
How do you set the values of the combobox grid so that the user can only select from the list when there are editing the data?
Thanks, John