TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
SELVAM S
NA
6
14.6k
Bind datagridviewcomboboxcolumn with generic collection
Apr 8 2012 7:45 AM
Hi,
I want to bind the following class as a collection of objects to a datagridview with one column as combobox.
public class GridClass
{
[DisplayName("ID")]
public string Id { get; set; }
[DisplayName("First Name")]
public string FirstName { get; set; }
[DisplayName("Last Name")]
public string LastName { get; set; }
[DisplayName("Gender")]
public List<string> Gender { get; set; }
public GridClass(string val)
{
Id = val;
FirstName = "FirstName" + val;
LastName = "LastName" + val;
Gender = new List<string>();
Gender.Add("MALE" + val);
Gender.Add("FEMALE" + val);
}
}
I created a datagridview called datagridview1.
Created 5 object of gridclass as follows
BindingList<GridClass> BindList = new BindingList<GridClass>();
for (int i = 1; i <= 5; i++)
{
GridClass g = new GridClass(i.ToString());
BindList.Add(g);
}
I binded to datagridview.
dataGridView1.DataSource = BindList;
But it is displaying only 3 columns ID, First Name and LastName.
I want to display Gender in combobox with each row will have different set of values.
Kindly reply for this post.
Thanks in advance
Reply
Answers (
1
)
Image in RichTextBox
Using WinForms and WPF in the same project