Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Nodes remain invisible after hiding all then showing some

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

Nodes remain invisible after hiding all then showing some
Link Posted: 26-May-2006 09:16
If one hides all nodes, by setting their hidden property to true, then setting the hidden property of one or more of the nodes to false does not reveal it.

You can reproduce this using the TreeView replacement example, as follows:
Select Add Root;
Select Hide selected;
Select Show hidden nodes.

Note that no nodes are visible.
Continue as follows:

Select Add Root.

Note that both the original and new root are now visible.
Link Posted: 26-May-2006 10:54
I've tried to reproduce - but all works fine.
Seems that you've modified this sample and deleted some of flyGrid.EndInit statements (this statement should finalize started BeginInit).
Link Posted: 29-May-2006 05:05
The sample file that I am using is your treeViewForm.vb, from your 1.4.0.7 distribution. It has a modification date of 1/16/2006. It includes the following methods.

   Private Sub hideSelectedBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles hideSelectedBtn.Click
      If Not treeviewGrid.Selected Is Nothing Then
        treeviewGrid.Selected.Hidden = True
      Else
        MessageBox.Show(\"Nothing selected!\")
      End If
    End Sub

    Private Sub showHiddenNodesBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles showHiddenNodesBtn.Click
      For Each n As Node In treeviewGrid.Rows.Items
        n.Hidden = False
        If n.HasChildren Then
          ShowNodes(n.Items)
        End If
      Next n
    End Sub

    Private Sub ShowNodes(ByVal nodes As NodeCollection)
      For Each n As Node In nodes
        n.Hidden = False
        If n.HasChildren Then
          ShowNodes(n.Items)
        End If
      Next n
    End Sub


These methods do not include any BeginInit()/EndInit() pairs.
I would not expect the pair to be required, given the documentation (below) and the fact that this code is updating the state of the nodes, not initializing the component.

The various .NET design environments use this method to start the initialization of a component that is used on a form or used by another component. The EndInit method ends the initialization. Using the BeginInit and EndInit methods prevents the control from being used before it is fully initialized.


In my own code, I included a BeginUpdate()/EndUpdate() pair, assuming that they would improve performance. I have not had to use BeginInit()/EndInit() in any of the other modifications that I have made to the nodes and everything else works fine.

Your treeViewForm.vb works properly as well, as long as there is at least one node in the tree that is not hidden. However, if you hide all of the nodes (e.g., per the instructions in my initial post) then they are not revealed when you set the hidden property to false.
Link Posted: 29-May-2006 06:45
Replace  showHiddenNodesBtn_Click by following code to solve this problem:
[VB.Net]
Private Sub showHiddenNodesBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles showHiddenNodesBtn.Click
  treeviewGrid.BeginInit()
  Try
    For Each n As Node In treeviewGrid.Rows.Items
      n.Hidden = False
      If n.HasChildren Then
        ShowNodes(n.Items)
      End If
    Next n
  Finally
    treeviewGrid.EndInit()
  End Try
End Sub


We'll solve problem to show hidden nodes without BeginInit/EndInit to the nearest update.