Rickus

Rickus

  • NA
  • 5
  • 0

Datagridview combobox column

Jun 19 2006 4:37 AM

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 :

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?


Answers (1)