.NET
  Home arrow .NET arrow Page 5 - The Why and How of the SplitContainer Cont...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

The Why and How of the SplitContainer Control
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2006-11-27

    Table of Contents:
  • The Why and How of the SplitContainer Control
  • The two orientations of SplitContainer Controls
  • Docking and Anchoring of Controls
  • Anchoring to prevent obscuring
  • Hide and reveal panels with nested SplitContainers
  • Events related to the SplitContainer Control

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The Why and How of the SplitContainer Control - Hide and reveal panels with nested SplitContainers


    (Page 5 of 6 )

    Just as you can embed a frameset within a frameset in HTML, so you can nest SplitContainer like matryoshka dolls, one inside the other, at the cost of real estate for each getting smaller and smaller. Add a SplitContainer to a form as shown. The default dock property is "fill," that is, the SplitContainer is attached to the four sides of the form. If you change this property to "none" you can make it smaller as shown in the picture.

    Click on Panel2 and double click the SplitContainer control in the tool box. This adds another vertical (default orientation) SplitContainer. Right click on Panel2 and choose to look at the properties of SplitContainer2 as shown.

    For SplitContainer2 change the orientation from vertical to horizontal. Add four buttons as marked. For the Form load event as well as the click event of the buttons, insert code as shown in the listing. Buttons are marked Button1 to Button 4 from top to bottom.

    Public Class nested
    Private Sub nested_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Me.Load
    SplitContainer2.IsSplitterFixed = True
    SplitContainer1.Panel1.BackColor = Color.GhostWhite
    SplitContainer2.Panel1.BackColor = Color.BlanchedAlmond
    SplitContainer2.Panel2.BackColor = Color.Ivory
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click  'Hide a panel 
    SplitContainer1.Panel1.Hide() End Sub Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click 'show a panel
    SplitContainer1.Panel1.Show() End Sub Private Sub Button3_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button3.Click
    'collapse a panel SplitContainer1.Panel1Collapsed = True End Sub Private Sub Button4_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button4.Click
    'do not collapse a panel, expand it SplitContainer1.Panel1Collapsed =
    False End Sub End Class

    The default panel color as well as the splitter is hard to see and sometimes disappears; hence "backcolor" was added to the panels to distinguish them from one another and to locate the splitters. While "Hide" and "Show" hide and show the panels, the Boolean values for the Panel collapsed property collapse and expand the panels as shown in the next picture when the Collapse Panel1 button is clicked.

    More .NET Articles
    More By Jayaram Krishnaswamy


       · This is a nice control to use in your navigation strategy. Also good for displaying...
       · With the splitter control it was possible to place controls like labels on...
     

    .NET ARTICLES

    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries
    - Introducing LINQ to SQL Designer using Visua...
    - Beginning LINQ to SQL Using Visual Studio 20...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway