This is a migrated thread and some comments may be shown as answers.

Nodes.Clear error after upgrading to 2011.3.11.1116

9 Answers 138 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Blas
Top achievements
Rank 1
Blas asked on 17 Nov 2011, 10:12 AM
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

9 Answers, 1 is accepted

Sort by
0
Marcus
Top achievements
Rank 1
answered on 17 Nov 2011, 10:34 AM
I can confirm this problem. I have it now in my project also.
0
Marcus
Top achievements
Rank 1
answered on 17 Nov 2011, 10:54 AM

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

0
Blas
Top achievements
Rank 1
answered on 17 Nov 2011, 11:13 AM
Hello Marcus,

Thank you for your answer, but I doesn't work for me. I get the same error with remove.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 17 Nov 2011, 11:53 AM
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
0
Blas
Top achievements
Rank 1
answered on 18 Nov 2011, 09:52 AM
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











0
Blas
Top achievements
Rank 1
answered on 18 Nov 2011, 11:38 AM
Solved with Nodes.Refresh
0
Julian Benkov
Telerik team
answered on 23 Nov 2011, 10:59 AM
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.

0
Steve
Top achievements
Rank 1
answered on 09 Dec 2016, 08:06 PM
I'm still getting an error in the BreadCrumb when calling treeview.Nodes.Clear() if a tree node is selected.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Dec 2016, 08:29 AM
Hello Steve,

Thank you for writing.  
 
Your question has already been answered in the other thread you have posted on the same topic. Please, see our answer there for more information.
We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled a forum thread.

Thank you for your understanding.

Regards,
Dess
Telerik by Progress
Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Tags
Treeview
Asked by
Blas
Top achievements
Rank 1
Answers by
Marcus
Top achievements
Rank 1
Blas
Top achievements
Rank 1
erwin
Top achievements
Rank 1
Veteran
Iron
Julian Benkov
Telerik team
Steve
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or