Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- InitializeComponent();
- radGridView1 = new RadGridView();
- radGridView1.Parent = this;
- radGridView1.Dock = DockStyle.Fill;
- NwindDataSetTableAdapters.EmployeesTableAdapter employeesTableAdapter = new EmployeesTableAdapter();
- employeesTableAdapter.Fill(this.nwindDataSet.Employees);
- BindingSource bs = new BindingSource();
- bs.DataMember = "Employees";
- bs.DataSource = this.nwindDataSet;
- radGridView1.DataSource = bs;
- LoadDetailsTable();
- radGridView1.ChildViewExpanded += radGridView1_ChildViewExpanded;
- }
- void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
- {
- e.ChildRow.ChildViewInfos[0].ChildRows[0].Height = 250;
- }
- void LoadDetailsTable()
- {
- DataTable table = new DataTable("Details");
- table.Columns.Add("EmployeeID", typeof(int));
- table.Columns.Add("Photo", typeof(byte[]));
- table.Columns.Add("FirstName", typeof(string));
- table.Columns.Add("LastName", typeof(string));
- table.Columns.Add("Title", typeof(string));
- table.Columns.Add("Address", typeof(string));
- table.Columns.Add("City", typeof(string));
- table.Columns.Add("BirthDate", typeof(DateTime));
- table.Columns.Add("Country", typeof(string));
- foreach (DataRow row in this.nwindDataSet.Employees.Rows)
- {
- table.Rows.Add(row["EmployeeID"], row["Photo"], row["FirstName"],
- row["LastName"], row["Title"], row["Address"], row["City"], row["BirthDate"], row["Country"]);
- }
- GridViewTemplate template = new GridViewTemplate();
- template.Caption = "Details";
- template.DataSource = table;
- template.AllowRowResize = false;
- template.ShowColumnHeaders = false;
- template.Columns["Photo"].Width = 125;
- template.Columns["City"].Width = 70;
- template.Columns["Country"].Width = 70;
- template.Columns["FirstName"].DisableHTMLRendering = false;
- template.Columns["Title"].DisableHTMLRendering = false;
- template.Columns["BirthDate"].DisableHTMLRendering = false;
- template.Columns["Address"].Width = 200;
- template.Columns["Address"].DisableHTMLRendering = false;
- this.radGridView1.Templates.Insert(0, template);
- GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate);
- relation.ChildTemplate = template;
- relation.ParentColumnNames.Add("EmployeeID");
- relation.ChildColumnNames.Add("EmployeeID");
- this.radGridView1.Relations.Add(relation);
- HtmlViewDefinition viewDef = new HtmlViewDefinition();
- viewDef.RowTemplate.Rows.Add(new RowDefinition());
- viewDef.RowTemplate.Rows.Add(new RowDefinition());
- viewDef.RowTemplate.Rows.Add(new RowDefinition());
- viewDef.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Photo", 0, 1, 3));
- viewDef.RowTemplate.Rows[0].Cells.Add(new CellDefinition("FirstName", 0, 1, 1));
- viewDef.RowTemplate.Rows[0].Cells.Add(new CellDefinition("BirthDate", 0, 2, 1));
- viewDef.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Title", 0, 3, 1));
- viewDef.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Address", 0, 1, 1));
- viewDef.RowTemplate.Rows[2].Cells.Add(new CellDefinition("City", 0, 1, 1));
- viewDef.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Country", 0, 1, 1));
- template.ViewDefinition = viewDef;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement