Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to make treenode style changed when mouse over it ?

how to make treenode style changed when mouse over it ?

Scheduled Pinned Locked Moved Visual Basic
tutorialquestionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sanyexian
    wrote on last edited by
    #1

    Hi,everyone! I used a treeview control in my application, I wanted to make treenodes like a href ,for example ,when my mouse move over it ,the font and color of treenode changed . I've done this in mousemove event. The code was like this

    Private Sub treeQiaoTi_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles treeQiaoTi.MouseMove
    Dim info As TreeViewHitTestInfo
    info = treeQiaoTi.HitTest(e.X, e.Y)
    If (info.Node IsNot Nothing And m_nodePre IsNot info.Node) Then
    info.Node.ForeColor = Color.Violet
    info.Node.NodeFont = New Font("微软雅黑", 10.5, FontStyle.Underline)

            If (m\_nodePre IsNot Nothing) Then
                m\_nodePre.ForeColor = Color.DarkBlue
                m\_nodePre.NodeFont = New Font(info.Node.NodeFont, FontStyle.Bold)
            End If
    
            m\_nodePre = info.Node
        End If
    End Sub
    

    But now, my question is ,when mouse move over unchecked treenode, I don't want them change color and font; I means how could judge treenodes whether checked or not ? Please give me some help and suggestions !Thx a lot !

    A 1 Reply Last reply
    0
    • S sanyexian

      Hi,everyone! I used a treeview control in my application, I wanted to make treenodes like a href ,for example ,when my mouse move over it ,the font and color of treenode changed . I've done this in mousemove event. The code was like this

      Private Sub treeQiaoTi_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles treeQiaoTi.MouseMove
      Dim info As TreeViewHitTestInfo
      info = treeQiaoTi.HitTest(e.X, e.Y)
      If (info.Node IsNot Nothing And m_nodePre IsNot info.Node) Then
      info.Node.ForeColor = Color.Violet
      info.Node.NodeFont = New Font("微软雅黑", 10.5, FontStyle.Underline)

              If (m\_nodePre IsNot Nothing) Then
                  m\_nodePre.ForeColor = Color.DarkBlue
                  m\_nodePre.NodeFont = New Font(info.Node.NodeFont, FontStyle.Bold)
              End If
      
              m\_nodePre = info.Node
          End If
      End Sub
      

      But now, my question is ,when mouse move over unchecked treenode, I don't want them change color and font; I means how could judge treenodes whether checked or not ? Please give me some help and suggestions !Thx a lot !

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Every TreeViewItem has a IsSelected property. I guess you could use that to check if that particular node is checked or not.

      The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick - Silverlight *.XCP files

      S 1 Reply Last reply
      0
      • A Abhinav S

        Every TreeViewItem has a IsSelected property. I guess you could use that to check if that particular node is checked or not.

        The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick - Silverlight *.XCP files

        S Offline
        S Offline
        sanyexian
        wrote on last edited by
        #3

        Hi,Abhinav,I've done what I wanted with this judge:

        If e.Node.Checked Then

        First judge the treenode whether checked or not, if it checked, changed its color! Still thank you for your suggestion!:cool:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups