With the image rectangle determined, here is the fun part: drawing the dotted lines. Walking the geometry of the node is done best by calculating the location of the center of the various parts (present or not), and then inflating their rectangles (if present), working backwards from the left of the label to the plus-minus button. Rectangle imgRect = new Rectangle(xPos, yPos, 0, 0) Image center int xPos = e. - SPACE_IL - imgW / 2 If ( base.ShowLines & base.ImageList != nullĬonst int SPACE_IL = 3 // space between Image and Label // Image size int imgW = NET wrapper fails to interpret this as SystemColors.GrayText and translates it to Color.Black. ![]() If the LineColor was not previously specified, the underlying Win32 control returns -1 (default color). BackgroundÄeriving from TreeView (surprise, surprise), in our constructor, we immediately fix a bug with the LineColor property. ![]() The proposed solution uses an owner-drawn TreeView (.NET 2.0) to draw the missing tree lines. This works fine for varying background colors, but only for a given set of image size, ItemHeight, and Indent. A possible remedy could use two transparent bitmaps, displaying the missing tree lines in a node's expanded and collapsed state. However, the blank space will look discomforting if tree lines are used. Using a dummy image or specifying an invalid image index, you can display a node without image. For special requirements, you might like using images only for some nodes. The TreeView allows either to show images for all nodes, or none at all. Download source and demo project - 18.5 Kb.
0 Comments
Leave a Reply. |