VB.NET - Combobox to datagridview - Asked By jenn on 26-Apr-10 04:51 PM

hello everyone

I have been searching high and low for how to do this:

On a windows form in Visual studio 2008, I have on the left side of my form a couple of comboboxes. On the right side of my form I have a datagridview. What I want to do is this:
When my friend selects choices from the comboboxes, I need it to automatically populate my gridview.

This is not being done online over the internet it is in house and there is no database.
just simply needs to copy her choices from the comboboxes into a gridview.

can someone please tell me how I can accomplish this?

I do not know anything about freakin datasets and yadda yadda yadda...just want a simple way to make this happen :)
Mohan Raj Aryal replied to jenn on 26-Apr-10 05:18 PM
You can use the code snipped something like this: 

     Dim gridRow As New DataGridViewRow
    Dim gridCell As DataGridViewCell
 
'Add the Selected first combobox value to grid
    gridCell = New DataGridViewTextBoxCell()
    gridCell.Value = ComboBox1.Text
    gridRow.Cells.Add(gridCell)
 
'Add the Selected second combobox value to grid
    gridCell = New DataGridViewTextBoxCell()
    gridCell.Value = ComboBox2.Text
    gridRow.Cells.Add(gridCell)
' Add others also if required
     
    DataGridView1.Rows.Add(gridRow)

jenn replied to Mohan Raj Aryal on 27-Apr-10 05:48 PM
okay..got it working! thank you :)