use a Datagridviwcomboboxcell in a binded datagridview
-
Hello I have a datagridview binded to a datatable : Wine This datatable contains CepageID Cepage percent DGV shows Cepage and percent I have another datatable Cepages When the user wants to edit a cepage in the DGV I want to switch the textboxcell to a comboboxcell showing the different available cepages Is it possible with a binded datagridview ? Thanks for any help
-
Hello I have a datagridview binded to a datatable : Wine This datatable contains CepageID Cepage percent DGV shows Cepage and percent I have another datatable Cepages When the user wants to edit a cepage in the DGV I want to switch the textboxcell to a comboboxcell showing the different available cepages Is it possible with a binded datagridview ? Thanks for any help
-
Why not use
DataGridViewComboboxColumn
right away?50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
Thanks for your answer ! I do not use Combobox column because I want to keep the normal textbox display when the cell is not editing ! Combobox display takes to much space in the grid to display the item properly !
Set these properties for your DataGridView as below:
comboboxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
yourDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
Set these properties for your DataGridView as below:
comboboxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
yourDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
-
Set these properties for your DataGridView as below:
comboboxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
yourDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
Hello d@nish Your suggestion was fine ! I've done it that way
cbxCepage.DataSource = sCodes.dtCepages; cbxCepage.DisplayMember = "Value"; cbxCepage.ValueMember = "ID"; cbxCepage.DataPropertyName = "ID"; dgvCepages.DataSource = null; dgvCepages.AutoGenerateColumns = false; dgvCepages.DataSource = Reg.Prod.dtCepages; dgvCepages.EditMode = DataGridViewEditMode.EditOnEnter; cbxCepage.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;