hi i runtime bind the data into datagridview combobox. But how do i make it to auto display the first item? i do not able find the selectedindex from DataGridViewComboBoxColumn.
DataGridViewComboBoxColumn cbStudentCourse = (DataGridViewComboBoxColumn)dgStudentCourse.Columns["studentCourseStatus"];
cbStudentCourse.DataSource = Enum.GetValues(typeof(CourseStudentStatus));
cbStudentCourse.DisplayIndex = 1;
-- Update ---
i saw someone doing this in solution 3
LInk
Are you sure i need such a long code to just have the first item selected??????
A DataGridViewComboBoxColumn has no
SelectedIndex
, andSelectedValue
properties. However you can get the same behavior ofSelectedValue
by setting theValue
property.For instance on first index the value member has value 2 then you should set
.Value = "2"
to set the first index selected.For example
In your case
Here is more details about DataGridViewComboBoxColumn
the best way to set the value of a datagridViewComboBoxCell is:
It worked with me very well