C# 2005 DataGridView - ComboBoxes - How do I ... ?

csharp Brazil
  • 15 years ago

    Hello everyone,

    Greetings from Brazil!  Please help! 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 I'm editing the value of SementeComboBoxColumn, the other values in this column disappear. 

     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";
                    this.EspecieComboBoxColumn.DataSource = this.tabSementesBindingSource;
                    this.EspecieComboBoxColumn.DisplayMember = "Semente";

    Thanks in advance,

    JC Carmo

  • 15 years ago

    Hi JC Carmo ,

    as i understand u want to set the values of 3rd combobox base on the values of the 1st combobox.

    if this  is ur prb then u can do one thing .

    if u a using JSP for that then when u select the values of 1st combobox then again reload that page and then select u can easily select the values of 3rd combobox on the basis of 1st one.

     i hope by this u get some help if  ur prb is not this then sorry for that .

    but if u need more help then u can mail me any time on [email protected]


    Nishant Kumar

  • 15 years ago


    Why don't u try writing eventhandlers and events, where in on the SelectedItemChanged event of the first combo box, the values of the third combo box can be changed.




  • 15 years ago
    You say that you're using C# 2005, so are you using a DataGrid as you say or are you actually using a DataGridView?  They are very not the same thing, so I thought that that should be cleared up.

  • 15 years ago

    Hi there,

    Sorry, I meant DataGridView  !  Good point ... I'm a newbie to C# and I still have some VB6 leftover terminology in my head!  Heheheh. Thanks for pointing that out.

    JC :)

  • 15 years ago
    It seems like an interesting idea, but, as a newbie, could I ask you to please send me some sample code for the EventHandler?  Thanks :)

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe