|
NodeExpandablePanel node control
Sunday, 13 September 2009
The NodeExpandablePanel node control is identical to the NodeExpandableTextBox node control, but shows any custom designed content instead of a text description.
To use it, subscribe to the MeasureNodeControlCustomArea and PaintNodeControlCustomArea treeview events to measure and draw an expandable area respectively, as shows below. Example: // create the node control. NodeExpandablePanel name = new NodeExpandablePanel(); name.AttachTo(tree); // add a node with the title and custom drawing area. NodeWithDescription node = new NodeWithDescription(); node.Text = "John Smith"; node.AttachTo(tree); // prepare treeview to auto–expanding. tree.Options.Node.AutoNodeHeight = true; tree.Options.Selection.HoverStyle = eHoverStyle.SoftSelect; // attach an event handlers to paint the expanded area. tree.MeasureNodeControlCustomArea += tree_MeasureNodeControlCustomArea; tree.PaintNodeControlCustomArea += tree_PaintNodeControlCustomArea; // measure our node control`s size. void tree_MeasureNodeControlCustomArea(FlexibleTreeView pTreeview, MeasureObjectEventArgs pArgs) { pArgs.Size = new Size(20, 20); } // draw our node control. private void tree_PaintNodeControlCustomArea(FlexibleTreeView pTreeview, NodeControlDrawEventArgs pArgs) { Rectangle bounds; //draw the 20x20 red rectangle. bounds = pArgs.Context.Bounds; bounds.Size = new Size(20, 20); using (Brush br = new SolidBrush(Color.Red)) { pArgs.Context.Graphics.FillRectangle(br, bounds); } } |
|