Using the TreeView control PDF Print E-mail

Tree view and list view are commons way of displaying information in a Windows application. This sample puts a node in a tree view.

  1.  
  2. using System;
  3. using System.Windows.Forms;
  4. class TreeSample : Form {
  5. public static void Main() {
  6. Application.Run( new TreeSample() );
  7. }
  8. TreeSample() {
  9. TreeView tv = new TreeView();
  10. tv.Parent = this;
  11. tv.Dock = DockStyle.Fill;
  12. TreeNode n = new TreeNode( "a node" );
  13. tv.Nodes.Add( n );
  14. }
  15. }
 

We declare a TreeView object and assign its Parent property to the main form of the application. We, then, set the Dock property to the value Fill of the DockStyle enumeration so that the TreeView object fills the whole client area of the application.

Then we declare a TreeNode object and add it to the Nodes collection maintained by the the TreeView object.




Bookmark it...
Digg!Reddit!Del.icio.us!Google!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!
 
< Prev
Joomla Template by Joomlashack
Joomla Templates by JoomlaShack Joomla Templates by Compass Design