C# 2005 - DataGridView and ComboBoxes questions

jcrcarmo

Active member
Joined
Dec 14, 2005
Messages
32
Hello everyone,

I have a DataGridView in a windows form with three columns:

Column1 is TipoComboBoxColumn
Column2 is QuantidadeColumn
Column3 is SementeComboBoxColumn

I need the SementeComboBoxColumn to display values according to the value I select in the TipoComboBoxColumn.

How do I go about accomplishing that? The code below works in part, BUT when Im editing the value of SementeComboBoxColumn, the other values for the other rows in this column disappear. This is driving nuts!


C#:
        private void tabBAdetDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (tabBAdetDataGridView.Columns[e.ColumnIndex].Name == "EspecieComboBoxColumn")
            {
                this.tabSementesTableAdapter.FillByTipo(this.sascrDataSet.tabSementes, tabBAdetDataGridView.Rows[e.RowIndex].Cells["TipoComboBoxColumn"].Value.ToString());
                this.EspecieComboBoxColumn.DataSource = this.tabSementesBindingSource;
                this.EspecieComboBoxColumn.DisplayMember = "Semente";
            }
            else
            {
                this.tabSementesTableAdapter.Fill(this.sascrDataSet.tabSementes);
                this.EspecieComboBoxColumn.DataSource = this.tabSementesBindingSource;
                this.EspecieComboBoxColumn.DisplayMember = "Semente";
            }
        }


Thanks in advance,

JC Carmo
 
Last edited by a moderator:
Try using a dataset and fetching a row from it, when a row is selected then bind each value to its appropriate combo box.
 
Back
Top