Nodes.Clear error after upgrading to 2011.3.11.1116

9 posts, 0 answers
  1. Blas
    Blas avatar
    55 posts
    Member since:
    Dec 2007

    Posted 17 Nov 2011 Link to this post

    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

  2. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 17 Nov 2011 Link to this post

    I can confirm this problem. I have it now in my project also.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marcus
    Marcus avatar
    17 posts
    Member since:
    Aug 2012

    Posted 17 Nov 2011 Link to this post

    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()

  5. Blas
    Blas avatar
    55 posts
    Member since:
    Dec 2007

    Posted 17 Nov 2011 Link to this post

    Hello Marcus,

    Thank you for your answer, but I doesn't work for me. I get the same error with remove.
  6. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 17 Nov 2011 Link to this post

    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
  7. Blas
    Blas avatar
    55 posts
    Member since:
    Dec 2007

    Posted 18 Nov 2011 Link to this post

    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











  8. Blas
    Blas avatar
    55 posts
    Member since:
    Dec 2007

    Posted 18 Nov 2011 Link to this post

    Solved with Nodes.Refresh
  9. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 23 Nov 2011 Link to this post

    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.

  10. Steve
    Steve avatar
    2 posts
    Member since:
    Sep 2012

    Posted 8 hours ago in reply to Julian Benkov Link to this post

    I'm still getting an error in the BreadCrumb when calling treeview.Nodes.Clear() if a tree node is selected.
Back to Top
UI for WinForms is Visual Studio 2017 Ready