Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Show/Hide All Nodes

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Show/Hide All Nodes
Link Posted: 13-Dec-2005 03:29
Hi all,

I wrote a couple of lines of code this morning to show and hide all the node in a flygrid I've been working on.  I've been successful at hiding all rows but for some strange reason once they are hidden I cannot get them back.

Here are the two methods I'm using to Show/Hide All Nodes:

    private void HideRows() {
      FieldGridNode fieldGridNode = this.Rows.RootNode.GetFirst() as FieldGridNode;

      while(fieldGridNode != null) {
        fieldGridNode.Hidden = true;  
        fieldGridNode = fieldGridNode.GetNext() as FieldGridNode;
      }
    }

    private void ShowRows() {
      FieldGridNode fieldGridNode = this.Rows.RootNode.GetFirst() as FieldGridNode;

      while(fieldGridNode != null) {
        fieldGridNode.Hidden = false;  
        fieldGridNode = fieldGridNode.GetNext() as FieldGridNode;
      }

      foreach (Column col in this.Columns.Items) {
        col.Visible = true;
      }
    }

I went as far as rolling each column to see if I could set them to visible in order to get my Nodes back, this did not work and was partially silly on my behalf because I've been able to see the column headers the whole time.

Any info is greatly appreciated,

Corey
Link Posted: 13-Dec-2005 04:07
Here is more optimal way to hide/show all nodes (it is enough to hide zero-level nodes to hide/show ALL nodes):
[C#]
private void HideShowRows(FlyGrid flyGrid, bool hide)
{
  flyGrid.BeginInit();
  try
  {
    foreach(Node node in flyGrid.Rows.Items)
      node.Hidden = hide;
  }
  finally
  {
    flyGrid.EndInit();
  }
}


If you need to totally hide/show nodes:
[C#]
private void HideShowNodes(FlyGrid flyGrid, bool hide)
{
  flyGrid.BeginInit();
  try
  {
    HideShowNodes(flyGrid.Rows.Items, hide);
  }
  finally
  {
     flyGrid.EndInit();
  }
}

private void HideShowNodes(NodeCollection nodes, bool hide)
{
  foreach(Node node in nodes)
  {
    if (node.HasChildren)
      HideShowNodes(node.Items, hide);
     node.Hidden = hide;
  }
}