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
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()
Thank you for your answer, but I doesn't work for me. I get the same error with remove.
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
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
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.
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