I'm having an issue with regards to having multiple node levels in the treeview.
First I load all the data into the treeview by binding a datatable as the the source.
When you drill down in a category you'll notice that the first two nodes are not flagged as Indeterminate, but when you click on the second node to open up its children the parent nodes get refreshed and get flagged as indeterminate.
'Loads tree nodes
Public Sub LoadItemCategories()
mItemCategoryDT = Datalayer.ItemCategoryRetrieveByRetail(ComboItemDataAsInt(cboRetail))
InitTree()
tvItemCat2.BeginUpdate()
tvItemCat2.DisplayMember = "ItemCat"
tvItemCat2.ParentMember = "PARENT_ITEM_CATEGORY_CD"
tvItemCat2.ChildMember = "ITEM_CATEGORY_CD"
tvItemCat2.DataSource = mItemCategoryDT
tvItemCat2.EndUpdate()
' tvItemCat2.ExpandAll()
AddHandler Me.tvItemCat2.NodeCheckedChanged, AddressOf tvItemCat2_NodeCheckedChanged
AddHandler Me.tvItemCat2.NodeFormatting, AddressOf tvItemCat2_NodeFormatting
End Sub
Private Sub tvItemCat2_NodeFormatting(sender As Object, e As TreeNodeFormattingEventArgs)
Dim data As DataRowView = TryCast(e.Node.DataBoundItem, DataRowView)
If data IsNot Nothing Then
Dim value As Object = data.Row("Checked")
If value Is DBNull.Value Then
e.Node.CheckState = ToggleState.Indeterminate
Else
e.Node.Checked = CBool(value)
End If
End If
End Sub