Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Treeview > Nodes.Clear error after upgrading to 2011.3.11.1116

Not answered Nodes.Clear error after upgrading to 2011.3.11.1116

Feed from this thread
  • Roberto Andrade Olivie avatar

    Posted on Nov 17, 2011 (permalink)

    Hello,

    I've upgraded today to version 2011.3.11.1116 and I'm experiencing a problem with treeview in existing projects.

    I have this code to fill a treeview (for example, depending on the project choose by user):

    Private Sub FillTree(Optional selPJerarquiaID As SqlHierarchyId = Nothing)
         treeEstructura.Enabled = False
         treeEstructura.DataSource = Nothing
         treeEstructura.Nodes.Clear()
         treeEstructura.DataSource = oProjects.Estructura.Items
         treeEstructura.Enabled = True
         treeEstructura.ExpandAll()
          
         If Not selPJerarquiaID.IsNull Then
             SelectNode(treeEstructura.Nodes(0).Nodes, selPJerarquiaID)
         Else
             treeEstructura.SelectedNode = treeEstructura.Nodes.First
         End If
     
     End Sub

    The first time works fine. The user choose a project and the treeview shows all tasks assigned to this project. But it doesn't work for  second time and it crashed in the sentence treeEstructura.Nodes.Clear raising the next error:

    "Object reference not set to an instance of an object"


    If I ignored this clear sentence, the treeview is not rebound with the right content, and continues to show the content that belong to the first project.


    Thank you in advance

    Reply

  • Marcus avatar

    Posted on Nov 17, 2011 (permalink)

    I can confirm this problem. I have it now in my project also.

    Reply

  • Marcus avatar

    Posted on Nov 17, 2011 (permalink)

    I have now (temporary) solved it by removing the nodes 1-by-1:

    rtvTest.BeginEdit()
    For ixIndex As Integer = rtvText.Nodes.Count - 1 To 0 Step -1
        Call rtvTest.Nodes(ixIndex).Remove()
    Next
    rtvTest.EndEdit()

    Reply

  • Roberto Andrade Olivie avatar

    Posted on Nov 17, 2011 (permalink)

    Hello Marcus,

    Thank you for your answer, but I doesn't work for me. I get the same error with remove.

    Reply

  • Posted on Nov 17, 2011 (permalink)

    I've also come across an error with TreeView.Nodes.Clear(). It hangs forever when used in lazy load/on-demand load scenarios.
    Filed a bug report and sample project.
    There seems to be something seriously wrong with RadTreeView in Q3.

    BTW: Roberto, have you tried leaving out the Nodes.Clear() call. This should not be necessary since you change the datasource, the tree should reload properly. Nodes.Clear() should not need to be called for bound trees.

    Regards
    Erwin

    Reply

  • Roberto Andrade Olivie avatar

    Posted on Nov 18, 2011 (permalink)

    Hello Erwin

    Thank you for your answer.

    The tree is bound to a List like this:

        Public Items As New List(Of cPlantillaEstructura)

    Using Me.treeEstructura.DeferRefresh()
               treeEstructura.DataSource = Nothing
               Windows.Forms.Application.DoEvents()
     
              
               ' treeEstructura.Nodes.Clear()
              

               treeEstructura.DataSource = oPLANTILLAS.Estructura.Items
               treeEstructura.DisplayMember = "PEstructuraDesc"
               treeEstructura.ParentMember = "ParentID"
               treeEstructura.ChildMember = "PJerarquiaID"
               treeEstructura.ValueMember = "PEstructuraID"
                
               treeEstructura.Enabled = True
               treeEstructura.ExpandAll()
               treeEstructura.Refresh()
           End Using

    In previous version of Telerik, it was requiered to clear nodes before binding the treeview. The treeview is not aware when the list is cleared.

    And here is the class:

    Public Class cPlantillaEstructura
        Implements INotifyPropertyChanged
        Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
        Protected Sub OnPropertyChanged(ByVal name As String)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
        End Sub
     
        Public Sub New()
            PEstructuraID = 0
            _PJerarquiaID = (New SqlHierarchyId).GetDescendant(Nothing, Nothing)
            PEstructuraDesc = "**CREANDO**"
            OnPropertyChanged("PJerarquiaID")
        End Sub
     
     
        Public Sub New(PEstructuraID As Integer, PJerarquiaID As SqlHierarchyId)
            PEstructuraID = PEstructuraID
            _PJerarquiaID = PJerarquiaID
            OnPropertyChanged("PJerarquiaID")
        End Sub
     
        Private _PEstructuraID As Integer
        Public Property PEstructuraID() As Integer
            Get
                Return _PEstructuraID
            End Get
            Set(value As Integer)
                _PEstructuraID = value
                OnPropertyChanged("PEstructuraID")
            End Set
        End Property
     
        Private _PEstructuraDesc As String
        Public Property PEstructuraDesc() As String
            Get
                Return _PEstructuraDesc
            End Get
            Set(value As String)
                _PEstructuraDesc = value
                OnPropertyChanged("PEstructuraDesc")
            End Set
        End Property
     
        Private _PTipoElemento As projectONE.clsPOdata.PlantillaTipoElemento
        Public Property PTipoElemento() As projectONE.clsPOdata.PlantillaTipoElemento
            Get
                Return _PTipoElemento
            End Get
            Set(value As projectONE.clsPOdata.PlantillaTipoElemento)
                _PTipoElemento = value
                OnPropertyChanged("PTipoElemento")
            End Set
        End Property
     
        Public ReadOnly Property IsNodo() As Boolean
            Get
                Return _PTipoElemento = clsPOdata.PlantillaTipoElemento.Nodo
            End Get
        End Property
     
        Public ReadOnly Property IsEtapa() As Boolean
            Get
                Return _PTipoElemento = clsPOdata.PlantillaTipoElemento.Etapa
            End Get
        End Property
     
        Public ReadOnly Property IsTarea() As Boolean
            Get
                Return _PTipoElemento = clsPOdata.PlantillaTipoElemento.Tarea
            End Get
        End Property
     
        Private _PJerarquiaID As SqlHierarchyId
        Public ReadOnly Property PJerarquiaID() As SqlHierarchyId
            Get
                Return _PJerarquiaID
            End Get
        End Property
     
        Public ReadOnly Property GetLevel() As Integer
            Get
                Return _PJerarquiaID.GetLevel()
            End Get
        End Property
     
        Public ReadOnly Property ParentID() As SqlHierarchyId
            Get
                Return _PJerarquiaID.GetAncestor(1)
            End Get
        End Property
     
        Private _Removed As Boolean
        Public Property Removed As Boolean
            Get
                Return _Removed
            End Get
            Set(value As Boolean)
                _Removed = value
            End Set
        End Property
     
     
    End Class

    Regards
    Roberto











    Reply

  • Roberto Andrade Olivie avatar

    Posted on Nov 18, 2011 (permalink)

    Solved with Nodes.Refresh

    Reply

  • Julian Benkov Julian Benkov admin's avatar

    Posted on Nov 23, 2011 (permalink)

    Hi guys,

    We have been analyzing the issues with Nodes.Clear() and the rebinding operation and we believe that we managed to address them. The internal build that will contain the fix should be available by the end of the current week.

    All the best,
    Julian Benkov
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Treeview > Nodes.Clear error after upgrading to 2011.3.11.1116
Related resources for "Nodes.Clear error after upgrading to 2011.3.11.1116"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]