Splitter クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class Splitter Inherits Control
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class Splitter : Control
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class Splitter : public Control

Splitter コントロールを使用すると、ユーザーが実行時に Splitter コントロールの端にドッキングされているコントロールのサイズを変更できます。ユーザーが Splitter コントロール上にマウス ポインタを通過させると、Splitter コントロールにドッキングされているコントロールのサイズが変更できることを示すためにカーソルが変化します。Splitter コントロールを使用すると、ユーザーは、ドッキング順序において直前にドッキングされたコントロールのサイズを変更できます。したがって、ユーザーがドッキングされたコントロールのサイズを変更できるようにするには、ユーザーによるサイズ変更を可能にするコントロールをコンテナの端にドッキングしてから、分割コントロールをそのコンテナの同じ側にドッキングします。たとえば、Windows エクスプローラに類似したウィンドウを作成するには、TreeView コントロールをフォームに追加し、その Dock プロパティを DockStyle.Left に設定します。Splitter コントロールをフォームに追加し、その Dock プロパティを同様に DockStyle.Left に設定します。フォーム レイアウトを完成するには、ListView コントロールを追加し、その Dock プロパティを DockStyle.Fill に設定して、ListView にフォーム上の残りの空間を占有させます。実行時に、Splitter コントロールを移動することによって、ユーザーは TreeView コントロールの幅を (同様に ListView コントロールの幅も) 変更できます。
ドッキングされたコントロールのサイズが、Splitter コントロールによってユーザーが使用できないほど小さくならないようにするには、MinExtra プロパティおよび MinSize プロパティを使用します。MinExtra プロパティおよび MinSize プロパティは、左右に (水平方向の Splitter コントロールの場合は上下に) ドッキングされるコントロールの最小の有効サイズを決定します。Splitter コントロールがドッキングされている、フォーム上のその他のコントロールが特定のスタイルの境界線を表示する場合は、BorderStyle プロパティを使用して、分割コントロールにドッキングされたコントロールの境界線スタイルを一致させることができます。
Splitter コントロールのドッキング先のコントロールに、サイズの上限を設定する必要が生じる場合があります。SplitterMoved イベントおよび SplitterMoving イベントを使用すると、ユーザーがどのような場合にドッキングされたコントロールのサイズを変更するのかを確認できます。SplitterMoved イベントまたは SplitterMoving イベントのイベント ハンドラで SplitPosition プロパティを使用して、Splitter コントロールがドッキングされているコントロールのサイズを決定し、SplitPosition プロパティを異なる値に設定して、ドッキングされたコントロールの幅を指定した最大幅 (または水平方向に配置された Splitter コントロールの場合は高さ) に制限できます。
![]() |
---|
Splitter コントロールを使用しているコントロールのサイズ変更は、マウスを使用する場合に限り実行できます。キーボードを使用して Splitter コントロールにはアクセスできません。 |

Splitter コントロールを TreeView コントロールおよび ListView コントロールと組み合わせて使用し、Windows エクスプローラに類似したウィンドウを作成するコード例を次に示します。TreeView コントロールおよび ListView コントロールを識別するには、ノードと項目を両方のコントロールに追加します。この例では、Splitter の MinExtra プロパティおよび MinSize プロパティを使用して、TreeView コントロールまたは ListView コントロールが小さすぎるサイズや大きすぎるサイズに変更されないようにしています。この例では、この例で作成されているメソッドを Form 内で定義し、その Form のコンストラクタから呼び出す必要があります。
Private Sub CreateMySplitControls() ' Create TreeView, ListView, and Splitter controls. Dim treeView1 As New TreeView() Dim listView1 As New ListView() Dim splitter1 As New Splitter() ' Set the TreeView control to dock to the left side of the form. treeView1.Dock = DockStyle.Left ' Set the Splitter to dock to the left side of the TreeView control. splitter1.Dock = DockStyle.Left ' Set the minimum size the ListView control can be sized to. splitter1.MinExtra = 100 ' Set the minimum size the TreeView control can be sized to. splitter1.MinSize = 75 ' Set the ListView control to fill the remaining space on the form. listView1.Dock = DockStyle.Fill ' Add a TreeView and a ListView item to identify the controls on the form. treeView1.Nodes.Add("TreeView Node") listView1.Items.Add("ListView Item") ' Add the controls in reverse order to the form to ensure proper location. Me.Controls.AddRange(New Control() {listView1, splitter1, treeView1}) End Sub 'CreateMySplitControls
private void CreateMySplitControls() { // Create TreeView, ListView, and Splitter controls. TreeView treeView1 = new TreeView(); ListView listView1 = new ListView(); Splitter splitter1 = new Splitter(); // Set the TreeView control to dock to the left side of the form. treeView1.Dock = DockStyle.Left; // Set the Splitter to dock to the left side of the TreeView control. splitter1.Dock = DockStyle.Left; // Set the minimum size the ListView control can be sized to. splitter1.MinExtra = 100; // Set the minimum size the TreeView control can be sized to. splitter1.MinSize = 75; // Set the ListView control to fill the remaining space on the form. listView1.Dock = DockStyle.Fill; // Add a TreeView and a ListView item to identify the controls on the form. treeView1.Nodes.Add("TreeView Node"); listView1.Items.Add("ListView Item"); // Add the controls in reverse order to the form to ensure proper location. this.Controls.AddRange(new Control[]{listView1, splitter1, treeView1}); }
private: void CreateMySplitControls() { // Create TreeView, ListView, and Splitter controls. TreeView^ treeView1 = gcnew TreeView; ListView^ listView1 = gcnew ListView; Splitter^ splitter1 = gcnew Splitter; // Set the TreeView control to dock to the left side of the form. treeView1->Dock = DockStyle::Left; // Set the Splitter to dock to the left side of the TreeView control. splitter1->Dock = DockStyle::Left; // Set the minimum size the ListView control can be sized to. splitter1->MinExtra = 100; // Set the minimum size the TreeView control can be sized to. splitter1->MinSize = 75; // Set the ListView control to fill the remaining space on the form. listView1->Dock = DockStyle::Fill; // Add a TreeView and a ListView item to identify the controls on the form. treeView1->Nodes->Add( "TreeView Node" ); listView1->Items->Add( "ListView Item" ); // Add the controls in reverse order to the form to ensure proper location. array<Control^>^temp0 = {listView1,splitter1,treeView1}; this->Controls->AddRange( temp0 ); }
private void CreateMySplitControls() { // Create TreeView, ListView, and Splitter controls. TreeView treeView1 = new TreeView(); ListView listView1 = new ListView(); Splitter splitter1 = new Splitter(); // Set the TreeView control to dock to the left side of the form. treeView1.set_Dock(DockStyle.Left); // Set the Splitter to dock to the left side of the TreeView control. splitter1.set_Dock(DockStyle.Left); // Set the minimum size the ListView control can be sized to. splitter1.set_MinExtra(100); // Set the minimum size the TreeView control can be sized to. splitter1.set_MinSize(75); // Set the ListView control to fill the remaining space on the form. listView1.set_Dock(DockStyle.Fill); // Add a TreeView and a ListView item to identify the controls on the // form. treeView1.get_Nodes().Add("TreeView Node"); listView1.get_Items().Add("ListView Item"); // Add the controls in reverse order to the form to ensure proper // location. this.get_Controls().AddRange(new Control[] { listView1, splitter1, treeView1 }); } //CreateMySplitControls

System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.Splitter


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSplitter クラスを検索する場合は、下記のリンクをクリックしてください。

- Splitter クラスのページへのリンク