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. Custom Draw TreeView problem - Painted "+" got overriden

Custom Draw TreeView problem - Painted "+" got overriden

Scheduled Pinned Locked Moved C#
graphicsdebugginghelpquestion
1 Posts 1 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.
  • D Offline
    D Offline
    DiegoValdevino
    wrote on last edited by
    #1

    I am creating a custom draw treeview with level 0 treenodes draw by the code below. I want to paint the entire node row, including behind the PlusMinus button with a color of choice. The problem happens with my code running after the PlusMinus button is painted,thus erasing it. Is there some event fired before OnDrawNode painting the "+" that i am missing and should override? Setting a breakpoint on the begining of OnDrawNode and seeing the control, shows me the "+" is already painted. protected override void OnDrawNode(DrawTreeNodeEventArgs e){ if (e.Node.Level == 0){ Rectangle nodeRegion = new Rectangle(ClientRectangle.X, e.Node.Bounds.Y, ClientRectangle.Width, e.Node.Bounds.Height); SolidBrush nodeBackColor = new SolidBrush(Color.BlanchedAlmond); SolidBrush nodeForeColor = new SolidBrush(Color.Black); Font nodeFont = (e.Node.NodeFont == null) ? this.Font : e.Node.NodeFont; e.Graphics.FillRectangle(nodeBackColor, nodeRegion); // PROBLEM e.Graphics.DrawString(e.Node.Text.Trim(), nodeFont, nodeForeColor, e.Node.Bounds.Location); } else{ e.DrawDefault = true; } base.OnDrawNode(e); } ps.: It looks like the OnPaint event isnt fired on a TreeView. Couldnt find why is this on MSDN. Thanks! Diego Valdevino

    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