abid zaid

abid zaid

  • NA
  • 11
  • 0

datagridviewcomboboxcolumn select the first item

Jan 8 2008 1:52 PM

Hi all,
I'm using a Datagridviewcomboboxcolumn in to dsiplay some data in my datagridview. After binding the data to the datagridviewcombobox how can i make it display the first item in the box by default?
My code is as follow
DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();
            DataTable dt = getData();//get data from database
            col.DataSource = dt;
            col.DisplayMember = "LastName";
            if (col.Items.Count > 0)//There is at least one item in the Combobox
            {
                //Select the first item
            }
            dataGridView1.Columns.Add(col);

Answers (10)