Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
10
Answers
datagridviewcomboboxcolumn select the first item
abid zaid
17y
26.2k
1
Reply
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);
Post
Reset
Cancel
Answers (
10
)
Next Recommended Forum
Dynamically Loading Forms
Making Flow Layout Panel Flow From Bottom Left to Bottom Right