using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace UltraGridHierarchical
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
List<MyChild> stankosKids = new List<MyChild>();
stankosKids.Add(new MyChild {Name = "Velimir", Gender = "Male"});
stankosKids.Add(new MyChild {Name = "Hilda", Gender = "Female"});
List<MyChild> arnoldsKids = new List<MyChild>();
arnoldsKids.Add(new MyChild {Name = "Thomas", Gender = "Male"});
arnoldsKids.Add(new MyChild {Name = "Sabrina", Gender = "Female"});
List<MyChild> chucksKids = new List<MyChild>();
chucksKids.Add(new MyChild {Name = "Bruce", Gender = "Male"});
chucksKids.Add(new MyChild {Name = "Lee", Gender = "Female"});
List<MyParent> list = new List<MyParent>();
list.Add(new MyParent {ID = 1, FirstName = "Stanko", LastName = "Milosev", Address = "Herseler strasse 8", MyKids = stankosKids});
list.Add(new MyParent {ID = 2, FirstName = "Arnold", LastName = "Schwarzeneger", Address = "Whitehouse 1", MyKids = arnoldsKids});
list.Add(new MyParent {ID = 3, FirstName = "Chuck", LastName = "Norris", Address = "Las Vegas", MyKids = chucksKids});
ultraGrid1.SetDataBinding(list, null);
}
public class MyParent
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public List<MyChild> MyKids { get; set; }
}
public class MyChild
{
public string Name { get; set; }
public string Gender { get; set; }
}
}
}
Source code.