On an MDI form I have a Navbar that is filled dynamically from a menu table in the database. I am creating the the groups and containers along with the corresponding treeviews by code as seen below. I must be doing something wrong because the treelist do not get loaded, only the groups show up with icons, names but they are empty. Could you tell me what is wrong with my code?
Best Regtards,
Cinar
Private Sub LoadExpBar(ByVal L1 As Integer, ByVal L2 As Integer)
NavBarControl1.Groups.Clear()
NavBarControl1.BeginUpdate()
Dim sql As String
sql = "SELECT L1,L2,L3,MenuText,Exp,LIcon,SIcon FROM " & menuTable & " where (NOT (MenuID IN ('1', '2', '3'))) ORDER BY cast(L1 as int),cast(L2 as int),cast(L3 as int)"
Dim cmd As New SqlCommand(sql, cnn)
Dim dr As SqlDataReader = cmd.ExecuteReader()
Dim x As DevExpress.XtraNavBar.NavBarGroup
Dim tw As DevExpress.XtraTreeList.TreeList
Dim xGr As Integer
xGr = 0
While dr.Read()
If dr(1) = 0 And dr(2) = 0 Then 'Main Group
If dr(0) <> 1 And dr(1) = 0 And dr(2) = 0 Then
tw.EndUnboundLoad()
x.ControlContainer.Controls.Add(tw)
End If
If Not dr(0).Equals(xGr) Then
x = NavBarControl1.Groups.Add()
x.Caption = dr(3).ToString
x.Hint = dr(4).ToString
x.Tag = dr(2).ToString
x.LargeImageIndex = IIf(IsDBNull(dr(5)), 10000, dr(5))
x.GroupStyle = NavBarGroupStyle.ControlContainer
x.Expanded = True
End If
ElseIf dr(2) = 0 Then 'tree
If dr(1) <> 0 And dr(1) <> 1 Then
tw.EndUnboundLoad()
x.ControlContainer.Controls.Add(tw)
End If
tw = New DevExpress.XtraTreeList.TreeList
tw.OptionsView.ShowColumns = False
tw.OptionsView.ShowHorzLines = False
tw.OptionsView.ShowIndicator = False
tw.BeginUnboundLoad()
Else
Dim Values As Object() = {dr(2).ToString}
Dim xNode As TreeListNode
xNode = tw.AppendNode(Values, -1, 0, 0, 0)
'xNode.HasChildren = True
End If
xGr = dr(0)
End While
dr.Close()
Me.NavBarControl1.EndUpdate()
End Sub