Home Forums WinForms controls Xceed Grid for WinForms hierarchical data binding to business objects in master/detail grid Reply To: hierarchical data binding to business objects in master/detail grid

User (Old forums)
Member
Post count: 23064

The objects have string properties which are displayed and then some other properties with the [Browsable(false)] attribute which aren’t displayed.  Then the two upper-level classes each have a generic list.  Something like the following, to continue with the Bank paradigm:

public class Bank
{
  readonly string name;
  readonly List<Branch> branches;

  public string Name
  {
    get { return name; }
  }

  public List<Branch> Branches
  {
    get { return branches; }
  }

  public Bank(string name, List<Branch> branches)
  {
    this.name = name;
    this.branches = branches;
  }  
}

public class Branch
{
  readonly string city;
  readonly List<Transaction> transactions;

  public string City
  {
    get { return city; }
  }

  public List<Transaction> Transactions
  {
    get { return transactions; }
  }

  public Branch(string city, List<Transaction> transactions)
  {
    this.city = city;
    this.transactions = transactions;
  }
}

public class Transaction
{
  readonly string amount;

  public string Amount
  {
    get { return amount; }
  }

  public Transaction(int amount)
  {
    this.amount = amount.ToString();
  }
}

at the top level:

List<Bank> banks;

and you already saw the code I’m using to try to bind to the grid. I do not use a DataSet when generating the data.  Establishing the relationship between the levels is precisely what I’m trying to figure out – at least in regards to relationships more than 2 levels deep.

Imported from legacy forums. Posted by ageer (had 712 views)