Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. protected override void OnLoad(EventArgs e)
  2. {
  3. base.OnLoad(e);
  4. InitializeComponent();
  5.  
  6. radGridView1 = new RadGridView();
  7. radGridView1.Parent = this;
  8. radGridView1.Dock = DockStyle.Fill;
  9.  
  10. NwindDataSetTableAdapters.EmployeesTableAdapter employeesTableAdapter = new EmployeesTableAdapter();
  11. employeesTableAdapter.Fill(this.nwindDataSet.Employees);
  12.  
  13. BindingSource bs = new BindingSource();
  14. bs.DataMember = "Employees";
  15. bs.DataSource = this.nwindDataSet;
  16. radGridView1.DataSource = bs;
  17.  
  18. LoadDetailsTable();
  19.  
  20. radGridView1.ChildViewExpanded += radGridView1_ChildViewExpanded;
  21. }
  22.  
  23. void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
  24. {
  25. e.ChildRow.ChildViewInfos[0].ChildRows[0].Height = 250;
  26. }
  27.  
  28. void LoadDetailsTable()
  29. {
  30. DataTable table = new DataTable("Details");
  31. table.Columns.Add("EmployeeID", typeof(int));
  32. table.Columns.Add("Photo", typeof(byte[]));
  33. table.Columns.Add("FirstName", typeof(string));
  34. table.Columns.Add("LastName", typeof(string));
  35. table.Columns.Add("Title", typeof(string));
  36. table.Columns.Add("Address", typeof(string));
  37. table.Columns.Add("City", typeof(string));
  38. table.Columns.Add("BirthDate", typeof(DateTime));
  39. table.Columns.Add("Country", typeof(string));
  40. foreach (DataRow row in this.nwindDataSet.Employees.Rows)
  41. {
  42. table.Rows.Add(row["EmployeeID"], row["Photo"], row["FirstName"],
  43. row["LastName"], row["Title"], row["Address"], row["City"], row["BirthDate"], row["Country"]);
  44. }
  45.  
  46. GridViewTemplate template = new GridViewTemplate();
  47. template.Caption = "Details";
  48. template.DataSource = table;
  49. template.AllowRowResize = false;
  50. template.ShowColumnHeaders = false;
  51. template.Columns["Photo"].Width = 125;
  52. template.Columns["City"].Width = 70;
  53. template.Columns["Country"].Width = 70;
  54. template.Columns["FirstName"].DisableHTMLRendering = false;
  55. template.Columns["Title"].DisableHTMLRendering = false;
  56. template.Columns["BirthDate"].DisableHTMLRendering = false;
  57. template.Columns["Address"].Width = 200;
  58. template.Columns["Address"].DisableHTMLRendering = false;
  59. this.radGridView1.Templates.Insert(0, template);
  60.  
  61. GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate);
  62. relation.ChildTemplate = template;
  63. relation.ParentColumnNames.Add("EmployeeID");
  64. relation.ChildColumnNames.Add("EmployeeID");
  65. this.radGridView1.Relations.Add(relation);
  66.  
  67. HtmlViewDefinition viewDef = new HtmlViewDefinition();
  68. viewDef.RowTemplate.Rows.Add(new RowDefinition());
  69. viewDef.RowTemplate.Rows.Add(new RowDefinition());
  70. viewDef.RowTemplate.Rows.Add(new RowDefinition());
  71. viewDef.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Photo", 0, 1, 3));
  72. viewDef.RowTemplate.Rows[0].Cells.Add(new CellDefinition("FirstName", 0, 1, 1));
  73. viewDef.RowTemplate.Rows[0].Cells.Add(new CellDefinition("BirthDate", 0, 2, 1));
  74. viewDef.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Title", 0, 3, 1));
  75. viewDef.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Address", 0, 1, 1));
  76. viewDef.RowTemplate.Rows[2].Cells.Add(new CellDefinition("City", 0, 1, 1));
  77. viewDef.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Country", 0, 1, 1));
  78. template.ViewDefinition = viewDef;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement