DekGenius.com
[ Team LiB ] Previous Section Next Section

TreeViewmarshal by reference, disposable

System.Windows.Forms (system.windows.forms.dll)class

This Control represents a hierarchical set of nodes in a tree view (similar to the Windows Explorer Folder View). You can add TreeNode objects to the Nodes collection. These are root nodes. To add further elements to the hierarchy you add additional TreeNode objects to the root TreeNode.Nodes collections. GetNodeCount() will return you the count of all nodes in the tree.

You can add CheckBoxes for each node, enable HotTracking (link-like) behavior, ShowLines and ShowRootLines (drawn from node to node), and ShowPlusMinus glyphs (little plus-shaped expansion boxes next to nodes with children). You can also set the distance by which to Indent each level of child nodes.

When you select an item, normally you are only permitted to click on imagery representing the label text. This can sometimes be awkward, so you can enable FullRowSelect to give users a larger target. HideSelection determines whether the selection highlight is displayed even when the control loses the focus. You can get or set the selected node with the SelectedNode property.

The nodes can be Sorted, and you can ExpandAll( ) and CollapseAll() nodes. To find the node under a particular point, you can use the GetNodeAt() method.

The tree raises events both Before and After select, check, collapse, and expand operations. If the control allows LabelEdit, you will also get BeforeLabelEdit and AfterLabelEdit events. The BeforeXXX events use the TreeViewCancelEventArgs class and can therefore be aborted.

public class TreeView : Control {
// Public Constructors
   public TreeView();
// Public Instance Properties
   public override Color BackColor{set; get; }
// overrides Control
   public override Image BackgroundImage{set; get; }
// overrides Control
   public BorderStyle BorderStyle{set; get; }
   public bool CheckBoxes{set; get; }
   public override Color ForeColor{set; get; }
// overrides Control
   public bool FullRowSelect{set; get; }
   public bool HideSelection{set; get; }
   public bool HotTracking{set; get; }
   public int ImageIndex{set; get; }
   public ImageList ImageList{set; get; }
   public int Indent{set; get; }
   public int ItemHeight{set; get; }
   public bool LabelEdit{set; get; }
   public TreeNodeCollection Nodes{get; }
   public string PathSeparator{set; get; }
   public bool Scrollable{set; get; }
   public int SelectedImageIndex{set; get; }
   public TreeNode SelectedNode{set; get; }
   public bool ShowLines{set; get; }
   public bool ShowPlusMinus{set; get; }
   public bool ShowRootLines{set; get; }
   public bool Sorted{set; get; }
   public override string Text{set; get; }
// overrides Control
   public TreeNode TopNode{get; }
   public int VisibleCount{get; }
// Protected Instance Properties
   protected override CreateParams CreateParams{get; }
// overrides Control
   protected override Size DefaultSize{get; }
// overrides Control
// Public Instance Methods
   public void BeginUpdate();
   public void CollapseAll();
   public void EndUpdate();
   public void ExpandAll();
   public TreeNode GetNodeAt(int x, int y);
   public TreeNode GetNodeAt(System.Drawing.Point pt);
   public int GetNodeCount(bool includeSubTrees);
   public override string ToString();  // overrides System.ComponentModel.Component
// Protected Instance Methods
   protected override void CreateHandle();  // overrides Control
   protected override void Dispose(bool disposing);  // overrides Control
   protected OwnerDrawPropertyBag GetItemRenderStyles(TreeNode node, int state);
   protected override bool IsInputKey(Keys keyData);  // overrides Control
   protected virtual void OnAfterCheck(TreeViewEventArgs e);
   protected virtual void OnAfterCollapse(TreeViewEventArgs e);
   protected virtual void OnAfterExpand(TreeViewEventArgs e);
   protected virtual void OnAfterLabelEdit(NodeLabelEditEventArgs e);
   protected virtual void OnAfterSelect(TreeViewEventArgs e);
   protected virtual void OnBeforeCheck(TreeViewCancelEventArgs e);
   protected virtual void OnBeforeCollapse(TreeViewCancelEventArgs e);
   protected virtual void OnBeforeExpand(TreeViewCancelEventArgs e);
   protected virtual void OnBeforeLabelEdit(NodeLabelEditEventArgs e);
   protected virtual void OnBeforeSelect(TreeViewCancelEventArgs e);
   protected override void OnHandleCreated(EventArgs e);  // overrides Control
   protected override void OnHandleDestroyed(EventArgs e);  // overrides Control
   protected virtual void OnItemDrag(ItemDragEventArgs e);
   protected override void OnKeyDown(KeyEventArgs e);  // overrides Control
   protected override void OnKeyPress(KeyPressEventArgs e);  // overrides Control
   protected override void OnKeyUp(KeyEventArgs e);  // overrides Control
   protected override void WndProc(ref Message m);  // overrides Control
// Events
   public event TreeViewEventHandler AfterCheck;
   public event TreeViewEventHandler AfterCollapse;
   public event TreeViewEventHandler AfterExpand;
   public event NodeLabelEditEventHandler AfterLabelEdit;
   public event TreeViewEventHandler AfterSelect;
   public event TreeViewCancelEventHandler BeforeCheck;
   public event TreeViewCancelEventHandler BeforeCollapse;
   public event TreeViewCancelEventHandler BeforeExpand;
   public event NodeLabelEditEventHandler BeforeLabelEdit;
   public event TreeViewCancelEventHandler BeforeSelect;
   public event ItemDragEventHandler ItemDrag;
   public event PaintEventHandler Paint;
// overrides Control
}

Hierarchy

System.Object System.MarshalByRefObject System.ComponentModel.Component(System.ComponentModel.IComponen, System.IDisposable) Control(IOleContro, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, IViewObject, IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage, IQuickActivate, System.ComponentModel.ISynchronizeInvoke, IWin32Window) TreeView

Returned By

TreeNode.TreeView

Passed To

TreeNode.FromHandle()

    [ Team LiB ] Previous Section Next Section