Kiran's Blog

Ramblings from a dehydrated mind…

  • Archives

  • Blog Stats

    • 9,866

Splitter Window in C#..

Posted by kiraninbng on August 13, 2006

Heres what it takes to create a splitter window with a listbox and treeview in C#,

 // Create the controls
 this.m_ListBox = new System.Windows.Forms.ListBox();
 this.m_Splitter = new System.Windows.Forms.Splitter();
 this.m_TreeView = new System.Windows.Forms.TreeView();
   
 // Set the docking properties of the control
 this.m_ListBox.Dock = System.Windows.Forms.DockStyle.Left;
 this.m_Splitter.Dock = System.Windows.Forms.DockStyle.Left;
 this.m_TreeView.Dock = System.Windows.Forms.DockStyle.Fill;

 // Set the properties of the control
 this.m_ListBox.Size = new System.Drawing.Size(120, 264);

 this.m_Splitter.Location = new System.Drawing.Point(120, 0);
 this.m_Splitter.Size = new System.Drawing.Size(3, 266);

 this.m_TreeView.Location = new System.Drawing.Point(123, 0);
 this.m_TreeView.Size = new System.Drawing.Size(169, 266);

It is even more simpler if you use the Form designer to get a splitter control working.Just add the controls and set the docking properties in the property window,no need to write a single line of code.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>