Hello,

J'ai quelques petits soucis lors de la création de mon Treeview.

1- j'ai caché mes noeuds enfant pour qu'il n'apparaissent que lorsque je clique sur le noeud parent.

Mais lorsque je clique sur le noeud parent, il m'ajoute le menu en dessou et l'expand ne se fait pas.

2- lorsqu'un noeud parent ne possède pas de noeud enfant, il vient se coller dans les noeuds enfant du précédent.

Pourriez-vous m'aider???

merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
<asp:TreeView ID="mnuPerso" runat="server" ExpandImageToolTip="" 
            NodeIndent="5" ShowExpandCollapse="False" showStartingNode="0" 
            AutoGenerateDataBindings="False" ExpandDepth="0">
            <ParentNodeStyle BorderStyle="None" BorderWidth="1px" Font-Bold="True" Font-Size="Small" ForeColor="#990000" Height="10px" Width="100%" HorizontalPadding="5px" />
            <SelectedNodeStyle Font-Underline="True" HorizontalPadding="10px" VerticalPadding="2px" BackColor="#EAEACD" Height="20px" Width="199px" />
            <RootNodeStyle Font-Bold="True" Font-Names="Arial" Font-Size="12pt" ForeColor="#990000" />
            <NodeStyle Font-Names="Arial" Font-Size="9pt" ForeColor="#990000" NodeSpacing="2px" VerticalPadding="2px" Width="100%" Height="10px" />
            <LeafNodeStyle Font-Strikeout="False" Height="10px" HorizontalPadding="15px" />
        </asp:TreeView>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
Public Sub showMenu(ByRef oDataSet As DataSet, ByRef mnuPerso As TreeView)
        ' Création du menu
 
        Dim parentNode As TreeNode      ' Création d'un noeud pour les éléments parents
        Dim childNode As TreeNode       ' création d'un noeud pour les éléments enfants
 
        Dim i As Integer = 0
        Dim sortSubMenu As String
        sortSubMenu = "LevelOrder ASC"
        Dim selectSubMenu As String
 
        For Each parentRows As DataRow In oDataSet.Tables("Menu").Select("MenuLevel = 0", sortSubMenu)
            parentNode = New TreeNode()
            parentNode.Text = parentRows.Item("libla")
            mnuPaschiweb.Nodes.AddAt(i, parentNode)
            selectSubMenu = "UpperLevel = " & parentRows.Item("ID").ToString
            For Each childRows As DataRow In oDataSet.Tables("Menu").Select(selectSubMenu, sortSubMenu)
                childNode = New TreeNode()
                childNode.Text = childRows.Item("libla")
                childNode.Expanded = False
                childNode.NavigateUrl = childRows.Item("MenuAction")
                mnuPaschiweb.Nodes(i).ChildNodes.Add(childNode)
            Next
            i = i + 1
        Next
    End Sub