Results 1 to 7 of 7

Thread: VB.NET Doesnt like this code

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    32

    VB.NET Doesnt like this code

    Ok here it is:

    Private Sub TreeView1_AfterSelect (blah blah blah)As Blah
    Select Case TreeView1.Nodes.IndexOf(e.Node)
    Case 0
    Label1.Hide()
    Case Is >0
    Label1.Show

    End Select
    End Sub


    It always hides! It never shows! It likes the code, but it doesnt use it right. What am I doing wrong, and if this isnt the right Sub then what action should i do it on. I am new to this TreeView Thing.

    Josh
    Smartbar XP is WAY better then Dashboard. http://www.smartbarxp.com

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Try this....

    Code:
    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
    
        Select Case e.Node.Index
            Case 0
                Label1.Hide()
            Case Is > 0
                Label1.Show()
        End Select
    
    End Sub

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Athley
    Try this....

    Code:
    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
    
        Select Case e.Node.Index
            Case 0
                Label1.Hide()
            Case Is > 0
                Label1.Show()
        End Select
    End Sub
    won't work either ..

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. Select Case TreeView1.Nodes.IndexOf(e.Node)
    2. Case 0
    3. Label1.Hide()
    4. Case Is < 0  'changed from > to <
    5.  Label1.Show()
    6. End Select
    works for me

  5. #5
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    quote:
    --------------------------------------------------------------------------------
    Originally posted by Athley
    Try this....


    code:--------------------------------------------------------------------------------Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, _
    ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

    Select Case e.Node.Index
    Case 0
    Label1.Hide()
    Case Is > 0
    Label1.Show()
    End Select
    End Sub
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------


    won't work either ..
    Kinda intresting that it worked for me!?!

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Athley
    Kinda intresting that it worked for me!?!
    when you descend the treeview index becomes upperindex + 1
    vice versa when you goint up gets -1

  7. #7
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    I'm not sure I understand what you mean, but I tried adding ten nodes to my treeview and the label is hidden when I select the topmost node and shows on all others....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width