C # Splitter Control SplitContainer

Source: Internet
Author: User
Splitter Control SplitContainer

Splitter control SplitContainer, is a container containing splitter splitter bar, which contains two panel container panel1,panel2, you can move the splitter bar to control the size of the panel!

Control to learn the sample program!

Attribute description;

Whether the split bar is enabled for disabling
BOOL Issplitterfixed{get;set;}
BOOL type, true: the splitter bar cannot be adjusted; False: The splitter bar can be used.
Determines whether the splitter can be moved by keyboard or mouse.

The direction of the splitter, split the control vertically and horizontally, up and down, and the left and right two-block panels
Orientation Orientation{get;set;}
Orientation is an enumeration; contains two values; horizontal and vertical; Vertical; Horizontal;

Get the size of the splitter bar (device)
Rectangle Splitterrectangle{get;}
Gets the rectangular representation of the splitter bar; the new Rectangle (x,y width,height) splitter means a split bar, a punctuation mark, and a wide-high
The splitter bar, which is represented by a rectangle.
The change of this property is related to the Orientation property. Vertical, horizontal display state, split bar position size is of course different.

Specify one of the splitter panels to remain unchanged
Adjust splitter, use Panel1 or Panel2 panel will not change size;
Fixedpanel Fixedpanel{get;set;}
Fixedpanel enumeration: Three values, None (default), Panel1, Panel2;
Determines which panel will remain unchanged after the Splittercontainer control is adjusted. When you resize a splitter container, you can maintain which panel is unchanged,
To set this property, you do not have to set this property if the container does not change.

Sets the initial size of the splitter from the container, splitting the left or top edge of the bar from the initial width of the container.
int Splitterdistance{get;set;}
In pixels, the default value is 40, and when you move the splitter, the value is changed to calculate the distance between the left edge or the top edge.
The initial distance of the splitter.

Set the incremental size of the drag splitter bar movement,
Which is the speed at which the drag moves. The same drag, the width of the move can be different.
int Splitterincrement{get;set;}
Gets the increment that sets the split bar move, with the default value of 1;
To test the size of the Splitterincrement property value, you can pass the keyboard up and down key, adjust the splitter, issplitterfixed must be true


Set the width of the splitter bar
int Splitterwidth{get;set;}
The default value is 4, which enables you to change the width of the splitter bar by setting this value.

Gets the fixed size of the left edge of the splitter and Panel1, or the distance of the top edge, and the default size of the edge to 25
int Panel1minsize{get;set;}
int Panel2minsize{get;set;}
This property is relatively large, you can control the size of the splitter's active range, that is, the fixed size of the left and right panels, the splitter can not
The area where the drag and drop enters.
Set the property to 0, indicating that the splitter can go to the edge.

Setting the Panel1 Panel2 of the splitter to fold or expand;
BOOL Panel1collapsed{get;set;}
BOOL Panel2collapsed{get;set;}

Note: The Panel1collapsed property, True is a fold, and false expands to the default value,
You cannot set the Splitterdistance,splitterwidth property in a split state, at which point the splitter has a hidden shutdown state,
You must expand to set these properties.

Pane1 and Pane2 Property Splitter two panel container
Splitterpanel Panel1{get}
Splitterpanel Panel2{get;}
Splitterpanel:panel type

This property setting if it conflicts with the Splitterdistance property, the initial position of the splitter bar is positioned with this attribute.

Event Description:
1:splittermoving Events
Occurs when a splitter is moved, during a split bar move.
delegate type; Splittercanceleventhandler
The data type is: Splittercanceleventargs:canceleventargs
Data member is: Splitx,splity,mousecursorx,mousecursory, represented in the workspace, mouse pointer, split bar sitting
Marked value.

SPLITX splity x coordinate point is the distance between the splitter and the container, and the vertical y is 0
Mousecursorx Mousecursory represents the point coordinates of the mouse pointer at work


2:splittermoved Events

Occurs after the splitter moves;
delegate type; SplitterEventHandler
data type; Splittereventargs:eventargs
data member; Splitx,splity,x,y represents the coordinate value of the mouse pointer and splitter bar in the workspace, which is the position value after the move.


Moving event refers to the mouse hold down the splitter, do not put, move, occurs, as long as the splitter move will occur, do not move the event does not occur.
The moved event occurs when the mouse is released after the splitter is moved. It occurs after the moving event.


Summary:

The Dock property of a control is set to fill, and the Click event of the form is not triggered because the control is blocked.

using system; using cshcn; using system.drawing; using system.componentmodel; using system.windows.forms; using system.threading; NAMESPACE&NBSP;CSHCN {       class program     {              [stathread]          static void main ()         {                 application.enablevisualstyles () ;              Application.setcompatibletextrenderingdefault (FALSE);             application.run (New Form1 ());         }          public  Class form1:form     { &nbsp                private  splitcontainer splitcontainer1;        private SplitContainer splitContainer2;        private Button buttonSplitterFixed;        private Button buttonOrientation;        private Label labelPanelCollapsed;        private Button buttonSplitterWidth;        private bool IsCollapsed=true;        private bool IsVer=true;        private bool IsSplitFixed=false;        private ToolTip toolTip;        public form1 ()         {              InitializeComponent ();         }        public void  initializecomponent ()         {               this.splitcontainer1=new splitcontainer ();            this.splitcontainer2=new splitcontainer ();            this.buttonsplitterfixed=new button ();            this.buttonorientation=new button ();            this.labelpanelcollapsed=new label ();            this.buttonsplitterwidth=new button ();    &nBsp;       this.tooltip=new tooltip ();            this.splitcontainer2.suspendlayout ();            this.splitcontainer1.suspendlayout ();            this. SuspendLayout ();            this.splitcontainer1.location=new point (10,10);            this.splitcontainer1.size=new size ( 480,420);            this.splitcontainer1.borderstyle= BORDERSTYLE.FIXED3D;            this.splitcontainer1.fixedpanel= Fixedpanel.panel1;            this.splitContainer1.SplitterDistance=100;            this.splitcontainer1.panel1minsize=0;            this.splitContainer1.SplitterWidth=4;            this.splitcontainer1.splittermoving+=new  splittercanceleventhandler (this.splitcontainer1_moving);            this.splitcontainer1.splittermoved+=new  splittereventhandler (this.splitcontainer1_moved);            this.splitcontainer2.backcolor= SystemColors.Control;            this.splitContainer2.Dock=DockStyle.Fill;            this.splitcontainer2.borderstyle= BORDERSTYLE.FIXED3D;            this.splitContainer2.SplitterWidth=4;            this.splitcontainer2.splitterincrement=6;            this.splitcontainer2.orientation= Orientation.horizontal;            this.splitContainer2.Panel2MinSize=100;            this.splitcontainer2.splittermoving+=new  splittercanceleventhandler (this.splitcontainer2_moving);            this.splitcontainer1.panel2.controls.add ( THIS.SPLITCONTAINER2);            this.labelPanelCollapsed.Location=new  Point (508,20);            this.labelpanelcollapsed.size=new size ( 35,35);            this.labelpanelcollapsed.backcolor= Color.yellowgreen;            this.labelPanelCollapsed.AutoSize=false;            this.labelpanelcollapsed.mouseenter+=new  eventhandler (This.labelpanelcollapsed_mouseenter);            this.labelpanelcollapsed.mouseleave+=new  eventhandler (This.labelpanelcollapsed_mouseleave);            this.labelPanelCollapsed.Click+=new  EventHandler (This.labelpanelcollapsed_click);            this.buttonsplitterfixed.text= "Locking splitter bar";            this.buttonSplitterFixed.Location=new  Point (508,70);            this.buttonSplitterFixed.Click+=new  EventHandler (This.buttonsplitterfixed_click);             &NBSP;&NBSP;&NBsp;        this.buttonorientation.text= "vertical/horizontal";            this.buttonOrientation.Location=new  Point (508,110);            this.buttonOrientation.Click+=new  EventHandler (This.buttonorientation_click);            this.buttonsplitterwidth.text= "split bar width";            this.buttonSplitterWidth.Location=new  Point (508,150);            this.buttonSplitterWidth.Click+=new  EventHandler (This.buttonsplitterwidth_click);            this.buttonsplitterwidth.mousemove+=new  mouseeventhandler (This.buttonsplitterwidth_mousemove);            this.buttonsplitterwidTh. Mouseleave+=new eventhandler (This.buttonsplitterwidth_mouseleave);                        this. text= "Splitter _splitcontainer";            this. Clientsize=new size (600,440);            this. Startposition=formstartposition.centerscreen;            this. Maximizebox=false;            this. Controls.AddRange (new control[] {this.splitcontainer1,this.buttonsplitterfixed,                                                     this.laBelpanelcollapsed,this.buttonorientation,                                                    this.buttonsplitterwidth});                         this.splitcontainer2.resumelayout (FALSE);            this.splitcontainer1.resumelayout (FALSE);            this. ResumeLayout (FALSE);         }                   private void buttonsplitterwidth_click (Object sender, Eventargs e)         {               splitcontainer1.splitterwidth+=4;         }         private  Void buttonsplitterwidth_mousemove (object sender,mouseeventargs e)          {             button  btn= (Button) sender;              tooltip.settooltip (BTN, "Width=   "+splitterwidth);         }         private  Void buttonsplitterwidth_mouseleave (object sender,eventargs e)          {              splitcontainer1.splitterwidth=4;      &NBSP;&NBSP;&NBSP}         private string splitterwidth          {                 get{return splitcontainer1.splitterwidth.tostring ();          }         private void  Buttonsplitterfixed_click (object sender,eventargs e)          {            if (!) issplitfixed)             {                  splitcontainer1.issplitterfixed= True                   Issplitfixed=true;             }              else             {                  splitContainer1.IsSplitterFixed=false;                   Issplitfixed=false;                              }                   private void labelpanelcollapsed_mouseenter (object  Sender,eventargs e)         {              for (int i=0;i<10;i++)              {                  thread.sleep (8);                   splitcontainer1.splitterdistance+=20;              }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.