Treeview control in VS2003

Discussion in 'ASP .Net Web Controls' started by CoreyMas, Apr 1, 2005.

  1. CoreyMas

    CoreyMas Guest

    Hello everyone,

    I have downloaded and installed the IE Web controls for Microsoft and I am
    using the Treeview control to display a simply hierarchy

    However, I cannot seem to get the Image associated with the node to align
    vertically (top) to the actual contents of the node.

    Example


    topnode
    (I want the Graphic here) line1 of middle node
    line2 of middle node
    (Graphic appears here) line3 of middle node
    line4 of middle node
    line5 of middle node
    (I want the graphic here) Line1 of end node
    (Graphic appears here) line2 of end node
    line3 of end node

    I am dynamically creating the nodes, and the code is as follows:


    Public Sub PopulateDataTree(ByVal ds As DataSet)
    Dim pma_keyrow As DataRow
    Dim newpmanode As TreeNode
    Dim spacebr11 As String = "<br>"
    Dim prevlevel1, prevlevel2, prevlevel3, prevlevel4 As String
    For Each pma_keyrow In ds.Tables("AllViewPMA").Rows
    ' Create the header row using the Level1, level2, level3, level4
    names
    If prevlevel1 = pma_keyrow("Level1Name") And prevlevel2 =
    pma_keyrow("Level2Name") And prevlevel3 = pma_keyrow("Level3Name") And
    prevlevel4 = pma_keyrow("Level4Name") Then
    ' do not add a new pma level node
    Else
    Dim LevelNameCombo As New StringBuilder
    With LevelNameCombo
    .Append(pma_keyrow("Level1Name").ToString)
    .Append("/")
    .Append(pma_keyrow("Level2Name").ToString)
    .Append("/")
    .Append(pma_keyrow("Level3Name").ToString)
    .Append("/")
    .Append(pma_keyrow("Level4Name").ToString)
    End With
    newpmanode = New TreeNode
    newpmanode.Text = LevelNameCombo.ToString
    newpmanode.SelectedImageUrl = "/GISWEB_DEV/GUI/IMAGES/pma.gif"
    newpmanode.ImageUrl = "/GISWEB_DEV/GUI/IMAGES/pma.gif"
    newpmanode.ExpandedImageUrl = "/GISWEB_DEV/GUI/IMAGES/pma.gif"
    treePMAView.Nodes.Add(newpmanode)
    End If
    Dim KeyNode As New TreeNode
    Dim KeyNameCombo As New StringBuilder
    With KeyNameCombo
    .Append("Location: ")
    .Append(pma_keyrow("LocCode"))
    .Append(spacebr11)
    .Append("Centre: ")
    .Append(pma_keyrow("PCCode"))
    .Append(spacebr11)
    .Append("Product: ")
    .Append(pma_keyrow("ProdCode"))
    .Append(spacebr11)
    .Append("Breakdown: ")
    .Append(pma_keyrow("BreCode"))
    .Append(spacebr11)
    .Append("Metric: ")
    .Append(pma_keyrow("MetCode"))
    .Append("<br>")
    End With
    KeyNode.Text = KeyNameCombo.ToString
    KeyNode.SelectedImageUrl = "/GISWEB_DEV/GUI/IMAGES/key.gif"
    KeyNode.ImageUrl = "/GISWEB_DEV/GUI/IMAGES/key.gif"
    KeyNode.DefaultStyle = New
    CssCollection("font-family:verdana;vertical-align:top;")
    KeyNode.ExpandedImageUrl = "/GISWEB_DEV/GUI/IMAGES/key.gif"
    newpmanode.Nodes.Add(KeyNode)
    Dim dv As DataView
    dv = New DataView(ds.Tables("AllDatakeyAttributes"),
    "PMA_DatakeyId = '" & pma_keyrow("PMA_DatakeyId").ToString & "'", "",
    DataViewRowState.CurrentRows)
    Dim attrrow As DataRowView
    Dim attrtext As String = ""
    For Each attrrow In dv
    Dim AttrNameCombo As New StringBuilder
    With AttrNameCombo
    .Append(attrrow("AttributeCodeValue"))
    .Append("<br>")
    End With
    attrtext = attrtext & AttrNameCombo.ToString
    Next
    If dv.Count > 0 Then
    Dim attrnode As New TreeNode
    attrnode.SelectedImageUrl =
    "/GISWEB_DEV/GUI/IMAGES/attributes.gif"
    attrnode.ImageUrl = "/GISWEB_DEV/GUI/IMAGES/attributes.gif"
    attrnode.ExpandedImageUrl =
    "/GISWEB_DEV/GUI/IMAGES/attributes.gif"
    attrnode.DefaultStyle = New
    CssCollection("font-family:verdana;vertical-align:top;")
    attrnode.Text = attrtext.Substring(0,
    attrtext.ToString.Length - 4)
    KeyNode.Nodes.Add(attrnode)
    End If
    prevlevel1 = pma_keyrow("Level1Name")
    prevlevel2 = pma_keyrow("Level2Name")
    prevlevel3 = pma_keyrow("Level3Name")
    prevlevel4 = pma_keyrow("Level4Name")
    Next
    End Sub

    How can I programatically set the alignment of the <tr> for the node to
    valign = top?

    Basically if i knew how to get to the <tr> or <td> tags that is being
    autogenerated by the control I could modify it with Valign = top which should
    solve my problem. However How do i do this?

    Thanks for all your help

    Corey
     
    CoreyMas, Apr 1, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frank Bishop

    VS2003 Control Form Size

    Frank Bishop, Feb 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    314
    William F. Robertson, Jr.
    Feb 4, 2005
  2. =?Utf-8?B?VHltYm93?=
    Replies:
    2
    Views:
    24,655
    =?Utf-8?B?VHltYm93?=
    Jan 10, 2006
  3. abargaddon
    Replies:
    0
    Views:
    1,104
    abargaddon
    Jan 17, 2008
  4. Per Salmi

    TreeView not rendering nodes? Cacheing of a TreeView

    Per Salmi, Oct 15, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    519
    Steve Drake
    Oct 15, 2003
  5. Ionutz
    Replies:
    2
    Views:
    571
    Ionutz
    Oct 23, 2005
Loading...

Share This Page