Skip to content

Datagridview combobox column

Rickus

Asked Jun 19, 2006, 12:37 AM EDT1 answer
Share
LinkedInX

Datagridview ComboBox Column.

I am trying to get the value of the selected item in the datagridview combobox column.
I set the column ValueMember and DisplayMember to a column of a database table like this :

Code
da.Fill(ds, "Commodity");
dv = ds.DefaultViewManager;
Commodity.DataSource = dv;
Commodity.ValueMember = "Commodity.Code";
Commodity.DisplayMember = Commodity.ValueMember;


I want to show the selected item in a messagbox.

Currently I have this (in a cell_leave event):

MessagBox.Show(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].ValueType.ToString());

This throws a "object reference not set to an instance of an object".

Can someone help please?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Sorry i meant :

    MessageBox.Show(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()

    0