Node rows are used to group regular rows that contain similar data. These can be created using the Subtotal method of C1FlexGridBase class or by using the GroupDescriptions property or by setting the IsNode property to true for certain rows. Rows.InsertNode method can also be used to insert a new node row at a specified index. These rows can be expanded or collapsed to display/hide the regular rows in each group.
This class represents such node rows and helps in manipulating these rows in the following ways:
private void Form1_Load(object sender, EventArgs e) { _flex = new C1FlexGrid(); _flex.Bounds = new System.Drawing.Rectangle(60,80,400,500); this.Controls.Add(_flex); _flex.Cols.Fixed = 0; _flex.Cols.Count = 1; _flex.Rows.Count = 1; _flex.ExtendLastCol = true; _flex.Tree.Column = 0; // Populate the grid. AddDirectory(@"c:\\", 0); } private void AddDirectory(string dir, int level) { // add this directory. string thisDir = Path.GetFileName(dir); if (thisDir.Length == 0) { thisDir = dir; } _flex.Rows.Add(); //make this new row a node Row row = _flex.Rows[_flex.Rows.Count - 1]; row.IsNode = true; //set node level Node nd = row.Node; nd.Data = thisDir; nd.Level = level; // add files in this directory. int cnt = 0; Row r; foreach (string file in Directory.GetFiles(dir)) { _flex.Rows.Add(); //mark the row without child row as node r = _flex.Rows[_flex.Rows.Count - 1]; r.IsNode = true; Node node = r.Node; node.Data = Path.GetFileName(file).ToLower(); node.Level = level + 1; cnt = cnt + 1; if (cnt > 10) break; } // add subdirectories (up to level 4). if (level <= 4) { cnt = 0; foreach (string subdir in Directory.GetDirectories(dir)) { AddDirectory(subdir, level + 1); cnt = cnt + 1; if (cnt > 10) break; } } } private void sortNodeAsc_Click(object sender, EventArgs e) { //Sorts the selected node in Ascending Order Node node = _flex.Rows[_flex.Row].Node; node.Sort(SortFlags.Ascending); } private void sortNodeDesc_Click(object sender, EventArgs e) { //Sorts the selected node in Descending Order Node node = _flex.Rows[_flex.Row].Node; node.Sort(SortFlags.Descending); }
System.Object
C1.Win.C1FlexGrid.Node