Reputation: 3295
I have a winform project containing a DataGridView
.
There is the column :
this.ColumnComboBox.FillWeight = 103.2981F;
this.ColumnComboBox.HeaderText = "Test ComboBox";
this.ColumnComboBox.Items.AddRange(new object[] {
"test1",
"test2",
"test3"});
this.ColumnComboBox.Name = "ColumnComboBox";
this.ColumnComboBox.ReadOnly = true;
I've try to set ReadOnly
to false in [Design] windows but the designer always replace it by the code above.
Also, my DataGridView contains this event :
private void Gridview1_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
{
switch (e.ColumnIndex)
{
// ComboBoxColumn
case 3:
DataGridViewComboBoxCell comboCell = Gridview1.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewComboBoxCell;
if (listItem[e.RowIndex] is DisplayComboClass)
{
comboCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
}
else
{
comboCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
}
break;
}
}
I don't know why but when I run my project, my DataGridView displays combobox when it's needed but I can't select a value. When I click on it, nothing happens, values "test1/2/3" doesn't appear.
Upvotes: 0
Views: 962
Reputation: 11
There is other setting that also preventing the draw of the combos if DataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; Hope helps some body.
Upvotes: 0
Reputation: 4513
Try,
DataGridView.ReadOnly = false;
after InitializeComponent()
,
Hope helps,
Upvotes: 2