or
| ... |
| panel.Children.Add(new RadButtonElement() { Text = "RadButtonElement" }); |
| panel.Children.Add(new MyRadButtonElement() { Text = "MyRadButtonElement" }); |
| } |
| class MyRadButtonElement : RadButtonElement |
| { |
| } |
| void Form1_Load(object sender, EventArgs e) |
| { |
| // Create element container to fill form |
| RadPanel elementsContainer = new RadPanel(); |
| this.Controls.Add(elementsContainer); |
| elementsContainer.Dock = DockStyle.Fill; |
| elementsContainer.BeginInit(); |
| elementsContainer.EndInit(); |
| // Create scroll viewer for scrollbar support |
| RadScrollViewer scrollViewer = new RadScrollViewer(); |
| elementsContainer.PanelElement.Children.Add(scrollViewer); |
| // Create panel to stack buttons |
| StackLayoutPanel panel = new StackLayoutPanel(); |
| scrollViewer.Viewport = panel; |
| panel.Orientation = Orientation.Vertical; |
| panel.Children.Add(new RadButtonElement() { Text = "RadButtonElement" }); |
| panel.Children.Add(new MyRadButtonElement() { Text = "MyRadButtonElement" }); |
| } |
| class MyRadButtonElement : RadButtonElement |
| { |
| } |
| RadGridView1.MasterGridViewTemplate.LoadFrom(reader) |
| private void rgvAdserverNetwork_ValueChanged(object sender, EventArgs e) |
| { |
| var cell = sender as GridDataCellElement; |
| if (cell == null || ((GridViewDataColumn)cell.ColumnInfo).FieldName != "Add") return; |
| var viewTemp = cell.ViewTemplate; |
| var tempRow = cell.RowElement; |
| var rowinfo = tempRow.RowInfo; |
| if (!(bool)cell.Value) |
| { |
| //loop the child items to set the checkbox to true |
| loopChilds(rowinfo); |
| rowinfo.Cells["Add"].Value = true; //set the checkbox of the parent to true |
| } |
| } |
| //loop the child items of the given master row |
| private void loopChilds(GridViewRowInfo masterrow) |
| { |
| var childRows = masterrow.ViewTemplate.ChildGridViewTemplates[0].GetChildRows(masterrow); |
| if (childRows == null) return; |
| var length = childRows.Length; |
| var expandedState = masterrow.IsExpanded; |
| masterrow.IsExpanded = true; |
| for (var i = 0; i < length; i++) |
| { |
| childRows[i].Cells["Add"].Value = true; //set the checkbox of the parent to true |
| } |
| masterrow.IsExpanded = expandedState; |
| } |