0
votes

I have a DataGridView which is data-bound to a BindingList. My DataGridView also has a couple of custom columns that I have added. These are not data-bound, but rather are generated based on items in my BindingList (ie: an item in my BindingList of type A has a property of type B; my custom column shows B.Name In this case, "Name" is a property of class B, and thus the property represented by the column is not directly found in the items in the BindingList).

Can anyone help me for this? I wanted to make it generic.

e.g.

public class Fruits
{
  public String Id {get;set}
  public String Name {get;set}
}

public class People
{
  public String ID {get;set}
  public String Name {get;set}
  public Fruits FavouriteFruit{get;set}
}

In BindingList as we can do sorting using custom sortable list for the properties on People, in the DatagridView but, I also wanted to sort People based on the FavouriteFruit.

1
I'm not sure, but I would guess that you need to add the column (and data) to the base DataSource..TaW

1 Answers

1
votes

You can inherit DataGRidView and add the required properties.