I try binding generic collection listContact to propGrid but output does not match what I expected. I want listContact to be shown like ListBox in propGrid. How do I do it? Thank you.
class Contact
{
public string Name { get; set; }
public string Address { get; set; }
}
PropertyGrid propGrid = new PropertyGrid();
List<Contact> listContact = new List<Contact>();
private void Form1_Load(object sender, EventArgs e)
{
listContact.Clear();
Contact newContact = null;
newContact = new Contact();
newContact.Name = "diana";
newContact.Address = "en";
listContact.Add(newContact);
newContact = null;
newContact = new Contact();
newContact.Name = "maxim";
newContact.Address = "cand";
listContact.Add(newContact);
propGrid.SelectedObject = listContact;
this.Controls.Add(propGrid);
propGrid.Dock = DockStyle.Fill;
}
You have to extend you class to use
ExpandableObjectConverter. This makes the parseable happen.See the below code. Just a fell examples. Pick the one you like the most.
The source used to code : MSDN