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. C#
  4. ownerdrawn treenodes

ownerdrawn treenodes

Scheduled Pinned Locked Moved C#
graphicshelpquestion
5 Posts 4 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.
  • X Offline
    X Offline
    xilefxilef
    wrote on last edited by
    #1

    Hi, While drawing treenodes, I'm having difficulties drawing the the boxes with pluses and minuses for node expansion. And also, I'm unable to simulate the hottracking action for each node when mousing over. Can you please help? thank you

    N M 2 Replies Last reply
    0
    • X xilefxilef

      Hi, While drawing treenodes, I'm having difficulties drawing the the boxes with pluses and minuses for node expansion. And also, I'm unable to simulate the hottracking action for each node when mousing over. Can you please help? thank you

      N Offline
      N Offline
      NavnathKale
      wrote on last edited by
      #2

      You need to elaborate your scenario to understand the problem u r facing :doh:

      1 Reply Last reply
      0
      • X xilefxilef

        Hi, While drawing treenodes, I'm having difficulties drawing the the boxes with pluses and minuses for node expansion. And also, I'm unable to simulate the hottracking action for each node when mousing over. Can you please help? thank you

        M Offline
        M Offline
        Migounette
        wrote on last edited by
        #3

        Maybe this code should help you to understand... : protected override void OnDrawNode(DrawTreeNodeEventArgs e) .... if ((e.Node != null) && (e.Node is MyTreeNode)) { MyTreeNode myTreeNode = e.Node as MyTreeNode; Rectangle bounds = e.Bounds; if (myTreeNode.CHECKBOX == true) { ControlPaint.DrawCheckBox(e.Graphics, bounds.Left, bounds.Top, 16, 16, ButtonState.Checked); bounds = Rectangle.Inflate(bounds, 16, 0); } // Draw the background and node text for a selected node. if ((e.State & TreeNodeStates.Selected) != 0) { // Draw the background of the selected node. The NodeBounds // method makes the highlight rectangle large enough to // include the text of a node tag, if one is present. e.Graphics.FillRectangle(Brushes.BlueViolet, bounds); // Retrieve the node font. If the node font has not been set, // use the TreeView font. Font nodeFont = e.Node.NodeFont; if (nodeFont == null) nodeFont = this.Font; // Draw the node text. e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(bounds, 2, 0)); } // Use the default background and node text. else { e.DrawDefault = true; } // If a node tag is present, draw its string representation // to the right of the label text. //e.Graphics.DrawString(e.Node.Tag.ToString(), this.Font, // Brushes.Yellow, e.Bounds.Right + 2, e.Bounds.Top); // If the node has focus, draw the focus rectangle large, making // it large enough to include the text of the node tag, if present. if ((e.State & TreeNodeStates.Focused) != 0) { using (Pen focusPen = new Pen(Color.Black)) { focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; Rectangle focusBounds = bounds; focusBounds.Size = new Size(focusBounds.Width - 1, focusBounds.Height - 1); e.Graphics.Dr

        X 1 Reply Last reply
        0
        • M Migounette

          Maybe this code should help you to understand... : protected override void OnDrawNode(DrawTreeNodeEventArgs e) .... if ((e.Node != null) && (e.Node is MyTreeNode)) { MyTreeNode myTreeNode = e.Node as MyTreeNode; Rectangle bounds = e.Bounds; if (myTreeNode.CHECKBOX == true) { ControlPaint.DrawCheckBox(e.Graphics, bounds.Left, bounds.Top, 16, 16, ButtonState.Checked); bounds = Rectangle.Inflate(bounds, 16, 0); } // Draw the background and node text for a selected node. if ((e.State & TreeNodeStates.Selected) != 0) { // Draw the background of the selected node. The NodeBounds // method makes the highlight rectangle large enough to // include the text of a node tag, if one is present. e.Graphics.FillRectangle(Brushes.BlueViolet, bounds); // Retrieve the node font. If the node font has not been set, // use the TreeView font. Font nodeFont = e.Node.NodeFont; if (nodeFont == null) nodeFont = this.Font; // Draw the node text. e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(bounds, 2, 0)); } // Use the default background and node text. else { e.DrawDefault = true; } // If a node tag is present, draw its string representation // to the right of the label text. //e.Graphics.DrawString(e.Node.Tag.ToString(), this.Font, // Brushes.Yellow, e.Bounds.Right + 2, e.Bounds.Top); // If the node has focus, draw the focus rectangle large, making // it large enough to include the text of the node tag, if present. if ((e.State & TreeNodeStates.Focused) != 0) { using (Pen focusPen = new Pen(Color.Black)) { focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; Rectangle focusBounds = bounds; focusBounds.Size = new Size(focusBounds.Width - 1, focusBounds.Height - 1); e.Graphics.Dr

          X Offline
          X Offline
          xilefxilef
          wrote on last edited by
          #4

          thanks. So I guess if I want those boxes with plus/minus to the left of the node for expansion and contraction, I need to draw them myself.

          D 1 Reply Last reply
          0
          • X xilefxilef

            thanks. So I guess if I want those boxes with plus/minus to the left of the node for expansion and contraction, I need to draw them myself.

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            xilefxilef wrote:

            I need to draw them myself

            That's what 'OwnerDrawm' is all about ;)

            Dave

            If this helped, please vote & accept answer!

            Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

            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