mercredi 6 mai 2015

How to add columns and data to treeviewadv of aga.controls

Private Class ColumnNode
    Inherits Node
    Public nodeControl11 As String = "" ' This sould make the DataPropertyName specified in the Node Collection.
    Public nodeControl21 As String = ""
    Public nodeControl31 As String = ""
    Public Sub New(ByVal nodeControl1 As String, ByVal nodeControl2 As String, ByVal nodeControl3 As String)
        nodeControl11 = nodeControl1
        nodeControl21 = nodeControl2
        nodeControl31 = nodeControl3
    End Sub
End Class


Private Sub Form2_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim col1 As String = "All Parent"

    Dim col2 As String = "Parent"
    Dim col3 As String = "All "
    Dim mmodel As TreeModel = New TreeModel()

    TreeViewAdv1.UseColumns = True

    Dim nodeControl11 As TreeColumn = New TreeColumn("Matcode", 100)
    Dim nodeControl21 As TreeColumn = New TreeColumn("Title", 200)
    Dim nodeControl31 As TreeColumn = New TreeColumn("Ref", 150)

    TreeViewAdv1.Model = mmodel
    TreeViewAdv1.Columns.Add(nodeControl11)
    TreeViewAdv1.Columns.Add(nodeControl21)
    TreeViewAdv1.Columns.Add(nodeControl31)

    Dim ntb As NodeTextBox = New NodeTextBox()
    ntb.DataPropertyName = "Text"
    ntb.ParentColumn = nodeControl11
    Dim ntb1 As NodeTextBox = New NodeTextBox()
    ntb1.DataPropertyName = "Text"
    ntb1.ParentColumn = nodeControl21
    Dim ntb2 As NodeTextBox = New NodeTextBox()
    ntb2.DataPropertyName = "Text"
    ntb2.ParentColumn = nodeControl31

    TreeViewAdv1.NodeControls.Add(ntb)
    TreeViewAdv1.NodeControls.Add(ntb1)
    TreeViewAdv1.NodeControls.Add(ntb2)
    For i = 0 To 20
        'Dim parentnode As Node = New Node("phild" & i.ToString.Trim)

        Dim parentnode As ColumnNode = New ColumnNode(col1, col2, col3)



        mmodel.Nodes.Add(parentnode)

        For j = 0 To 2
            ' Dim childnode As Node = New Node("child" & j.ToString.Trim)
            Dim childnode As ColumnNode = New ColumnNode(col3, col1, col2)


            parentnode.Nodes.Add(childnode)


        Next j

    Next i


    TreeViewAdv1.Visible = True

End Sub

The above code is what I have converted from C# to vb.net, displayed in the link below how to add items to TreeViewAdv in multi-column mode with winforms

However, it is not producing the desired result. What change shall made in the code to add data for each column and display it in the treeviewAdv?

I am getting +/- and lines, which compels me to anticipate that nodes are created but not displayed.

Any suggestion with a working model please?

Aucun commentaire:

Enregistrer un commentaire