c#之splitcontainer類(介面)
tcbs系統中用到,故大約瞭解下用法:
下面的程式碼示例演示一個垂直的和一個水平的 SplitContainer。 垂直拆分器以 10 個畫素的增量移動。 該垂直 SplitContainer 的左皮膚包含一個 TreeView 控制元件,其右皮膚包含一個水平 SplitContainer。 水平 SplitContainer 的兩個皮膚都填充 ListView 控制元件,上面的皮膚定義為一個 FixedPanel,所以當調整容器大小時其大小不會調整。 移動垂直拆分器將引發 SplitterMoving 事件,在本示例中表現為游標樣式發生變化。 在停止移動拆分器時引發 SplitterMoved 事件。 本示例中透過將游標樣式還原為預設樣式來表示它。
VB
C#
C++
F#
JScript
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.ListView listView2;
private System.Windows.Forms.ListView listView1;
public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
splitContainer1 = new System.Windows.Forms.SplitContainer();
treeView1 = new System.Windows.Forms.TreeView();
splitContainer2 = new System.Windows.Forms.SplitContainer();
listView1 = new System.Windows.Forms.ListView();
listView2 = new System.Windows.Forms.ListView();
splitContainer1.SuspendLayout();
splitContainer2.SuspendLayout();
SuspendLayout();
// Basic SplitContainer properties.
// This is a vertical splitter that moves in 10-pixel increments.
// This splitter needs no explicit Orientation property because Vertical is the default.
splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
splitContainer1.ForeColor = System.Drawing.SystemColors.Control;
splitContainer1.Location = new System.Drawing.Point(0, 0);
splitContainer1.Name = "splitContainer1";
// You can drag the splitter no nearer than 30 pixels from the left edge of the container.
splitContainer1.Panel1MinSize = 30;
// You can drag the splitter no nearer than 20 pixels from the right edge of the container.
splitContainer1.Panel2MinSize = 20;
splitContainer1.Size = new System.Drawing.Size(292, 273);
splitContainer1.SplitterDistance = 79;
// This splitter moves in 10-pixel increments.
splitContainer1.SplitterIncrement = 10;
splitContainer1.SplitterWidth = 6;
// splitContainer1 is the first control in the tab order.
splitContainer1.TabIndex = 0;
splitContainer1.Text = "splitContainer1";
// When the splitter moves, the cursor changes shape.
splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(splitContainer1_SplitterMoved);
splitContainer1.SplitterMoving += new System.Windows.Forms.SplitterCancelEventHandler(splitContainer1_SplitterMoving);
// Add a TreeView control to the left panel.
splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control;
// Add a TreeView control to Panel1.
splitContainer1.Panel1.Controls.Add(treeView1);
splitContainer1.Panel1.Name = "splitterPanel1";
// Controls placed on Panel1 support right-to-left fonts.
splitContainer1.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
// Add a SplitContainer to the right panel.
splitContainer1.Panel2.Controls.Add(splitContainer2);
splitContainer1.Panel2.Name = "splitterPanel2";
// This TreeView control is in Panel1 of splitContainer1.
treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
treeView1.ForeColor = System.Drawing.SystemColors.InfoText;
treeView1.ImageIndex = -1;
treeView1.Location = new System.Drawing.Point(0, 0);
treeView1.Name = "treeView1";
treeView1.SelectedImageIndex = -1;
treeView1.Size = new System.Drawing.Size(79, 273);
// treeView1 is the second control in the tab order.
treeView1.TabIndex = 1;
// Basic SplitContainer properties.
// This is a horizontal splitter whose top and bottom panels are ListView controls. The top panel is fixed.
splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
// The top panel remains the same size when the form. is resized.
splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
splitContainer2.Location = new System.Drawing.Point(0, 0);
splitContainer2.Name = "splitContainer2";
// Create the horizontal splitter.
splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
splitContainer2.Size = new System.Drawing.Size(207, 273);
splitContainer2.SplitterDistance = 125;
splitContainer2.SplitterWidth = 6;
// splitContainer2 is the third control in the tab order.
splitContainer2.TabIndex = 2;
splitContainer2.Text = "splitContainer2";
// This splitter panel contains the top ListView control.
splitContainer2.Panel1.Controls.Add(listView1);
splitContainer2.Panel1.Name = "splitterPanel3";
// This splitter panel contains the bottom ListView control.
splitContainer2.Panel2.Controls.Add(listView2);
splitContainer2.Panel2.Name = "splitterPanel4";
// This ListView control is in the top panel of splitContainer2.
listView1.Dock = System.Windows.Forms.DockStyle.Fill;
listView1.Location = new System.Drawing.Point(0, 0);
listView1.Name = "listView1";
listView1.Size = new System.Drawing.Size(207, 125);
// listView1 is the fourth control in the tab order.
listView1.TabIndex = 3;
// This ListView control is in the bottom panel of splitContainer2.
listView2.Dock = System.Windows.Forms.DockStyle.Fill;
listView2.Location = new System.Drawing.Point(0, 0);
listView2.Name = "listView2";
listView2.Size = new System.Drawing.Size(207, 142);
// listView2 is the fifth control in the tab order.
listView2.TabIndex = 4;
// These are basic properties of the form.
ClientSize = new System.Drawing.Size(292, 273);
Controls.Add(splitContainer1);
Name = "Form1";
Text = "Form1";
splitContainer1.ResumeLayout(false);
splitContainer2.ResumeLayout(false);
ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void splitContainer1_SplitterMoving(System.Object sender, System.Windows.Forms.SplitterCancelEventArgs e)
{
// As the splitter moves, change the cursor type.
Cursor.Current = System.Windows.Forms.Cursors.NoMoveVert;
}
private void splitContainer1_SplitterMoved(System.Object sender, System.Windows.Forms.SplitterEventArgs e)
{
// When the splitter stops moving, change the cursor back to the default.
Cursor.Current=System.Windows.Forms.Cursors.Default;
}
}
下面的程式碼示例演示一個垂直的和一個水平的 SplitContainer。 垂直拆分器以 10 個畫素的增量移動。 該垂直 SplitContainer 的左皮膚包含一個 TreeView 控制元件,其右皮膚包含一個水平 SplitContainer。 水平 SplitContainer 的兩個皮膚都填充 ListView 控制元件,上面的皮膚定義為一個 FixedPanel,所以當調整容器大小時其大小不會調整。 移動垂直拆分器將引發 SplitterMoving 事件,在本示例中表現為游標樣式發生變化。 在停止移動拆分器時引發 SplitterMoved 事件。 本示例中透過將游標樣式還原為預設樣式來表示它。
VB
C#
C++
F#
JScript
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.ListView listView2;
private System.Windows.Forms.ListView listView1;
public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
splitContainer1 = new System.Windows.Forms.SplitContainer();
treeView1 = new System.Windows.Forms.TreeView();
splitContainer2 = new System.Windows.Forms.SplitContainer();
listView1 = new System.Windows.Forms.ListView();
listView2 = new System.Windows.Forms.ListView();
splitContainer1.SuspendLayout();
splitContainer2.SuspendLayout();
SuspendLayout();
// Basic SplitContainer properties.
// This is a vertical splitter that moves in 10-pixel increments.
// This splitter needs no explicit Orientation property because Vertical is the default.
splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
splitContainer1.ForeColor = System.Drawing.SystemColors.Control;
splitContainer1.Location = new System.Drawing.Point(0, 0);
splitContainer1.Name = "splitContainer1";
// You can drag the splitter no nearer than 30 pixels from the left edge of the container.
splitContainer1.Panel1MinSize = 30;
// You can drag the splitter no nearer than 20 pixels from the right edge of the container.
splitContainer1.Panel2MinSize = 20;
splitContainer1.Size = new System.Drawing.Size(292, 273);
splitContainer1.SplitterDistance = 79;
// This splitter moves in 10-pixel increments.
splitContainer1.SplitterIncrement = 10;
splitContainer1.SplitterWidth = 6;
// splitContainer1 is the first control in the tab order.
splitContainer1.TabIndex = 0;
splitContainer1.Text = "splitContainer1";
// When the splitter moves, the cursor changes shape.
splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(splitContainer1_SplitterMoved);
splitContainer1.SplitterMoving += new System.Windows.Forms.SplitterCancelEventHandler(splitContainer1_SplitterMoving);
// Add a TreeView control to the left panel.
splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control;
// Add a TreeView control to Panel1.
splitContainer1.Panel1.Controls.Add(treeView1);
splitContainer1.Panel1.Name = "splitterPanel1";
// Controls placed on Panel1 support right-to-left fonts.
splitContainer1.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
// Add a SplitContainer to the right panel.
splitContainer1.Panel2.Controls.Add(splitContainer2);
splitContainer1.Panel2.Name = "splitterPanel2";
// This TreeView control is in Panel1 of splitContainer1.
treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
treeView1.ForeColor = System.Drawing.SystemColors.InfoText;
treeView1.ImageIndex = -1;
treeView1.Location = new System.Drawing.Point(0, 0);
treeView1.Name = "treeView1";
treeView1.SelectedImageIndex = -1;
treeView1.Size = new System.Drawing.Size(79, 273);
// treeView1 is the second control in the tab order.
treeView1.TabIndex = 1;
// Basic SplitContainer properties.
// This is a horizontal splitter whose top and bottom panels are ListView controls. The top panel is fixed.
splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
// The top panel remains the same size when the form. is resized.
splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
splitContainer2.Location = new System.Drawing.Point(0, 0);
splitContainer2.Name = "splitContainer2";
// Create the horizontal splitter.
splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
splitContainer2.Size = new System.Drawing.Size(207, 273);
splitContainer2.SplitterDistance = 125;
splitContainer2.SplitterWidth = 6;
// splitContainer2 is the third control in the tab order.
splitContainer2.TabIndex = 2;
splitContainer2.Text = "splitContainer2";
// This splitter panel contains the top ListView control.
splitContainer2.Panel1.Controls.Add(listView1);
splitContainer2.Panel1.Name = "splitterPanel3";
// This splitter panel contains the bottom ListView control.
splitContainer2.Panel2.Controls.Add(listView2);
splitContainer2.Panel2.Name = "splitterPanel4";
// This ListView control is in the top panel of splitContainer2.
listView1.Dock = System.Windows.Forms.DockStyle.Fill;
listView1.Location = new System.Drawing.Point(0, 0);
listView1.Name = "listView1";
listView1.Size = new System.Drawing.Size(207, 125);
// listView1 is the fourth control in the tab order.
listView1.TabIndex = 3;
// This ListView control is in the bottom panel of splitContainer2.
listView2.Dock = System.Windows.Forms.DockStyle.Fill;
listView2.Location = new System.Drawing.Point(0, 0);
listView2.Name = "listView2";
listView2.Size = new System.Drawing.Size(207, 142);
// listView2 is the fifth control in the tab order.
listView2.TabIndex = 4;
// These are basic properties of the form.
ClientSize = new System.Drawing.Size(292, 273);
Controls.Add(splitContainer1);
Name = "Form1";
Text = "Form1";
splitContainer1.ResumeLayout(false);
splitContainer2.ResumeLayout(false);
ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void splitContainer1_SplitterMoving(System.Object sender, System.Windows.Forms.SplitterCancelEventArgs e)
{
// As the splitter moves, change the cursor type.
Cursor.Current = System.Windows.Forms.Cursors.NoMoveVert;
}
private void splitContainer1_SplitterMoved(System.Object sender, System.Windows.Forms.SplitterEventArgs e)
{
// When the splitter stops moving, change the cursor back to the default.
Cursor.Current=System.Windows.Forms.Cursors.Default;
}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-706035/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- C#中介面、基類與類C#
- C#之介面C#
- c# interface介面之C#
- C#基礎概念之密封類,屬性訪問器,介面C#
- c#之hashtable類C#
- c#之oracledataAdapter類C#OracleAPT
- C# OOP:繼承,介面和抽象類C#OOP繼承抽象
- C#基礎之介面(6)C#
- C#點滴 - 抽象類與介面區別C#抽象
- C#泛型類之LISTC#泛型
- 全面剖析C#介面程式設計之定義介面C#程式設計
- 介面、抽象類、普通類之間的關係抽象
- TS系列之介面/類/泛型泛型
- c#之基類派生類base_小記C#
- c#之arraylist類的成員C#
- c#之基類派生類base_小記(2)C#
- C#虛基類繼承與介面的區別C#繼承
- C#之 sealed(密封類和密封方法)C#
- c#之stream相關類小記C#
- c# tcbs之類中方法的特徵C#特徵
- C#設計模式之介面卡模式C#設計模式
- JAVA基礎之介面與內部類Java
- JMockit學習之mock介面和抽象類Mock抽象
- C#介面、抽象類、普通類和繼承(子類與父類)都有其特定的用途和場景C#抽象繼承
- 走進C# abstract,瞭解抽象類與介面的異同C#抽象
- 77. C#中的介面和類有什麼異同?C#
- C#介面interfaceC#
- c# interface介面C#
- C#介面配置C#
- Java學習筆記之介面和抽象類Java筆記抽象
- Java基礎之介面與抽象類及多型、內部類Java抽象多型
- c#之.NET Framework 類庫_名稱空間C#Framework
- 物件導向 -- 三大特性之繼承 補充 抽象類 介面類物件繼承抽象
- c# tcbs之外部類成員型別為內部類之示例C#型別
- 有關“抽象類”和“介面”的異同之處?抽象
- 類微信介面
- 【物件導向】C# 為什麼用介面例項化一個實現該介面的類?物件C#
- 登入介面(C#)C#