作成日: 2019/01/23 最終更新日: 2019/01/23
文書種別
使用方法
詳細
本コントロールでは、縮小ハンドル(下部の半円形アイコン)をクリックしてパネルを閉じるとハンドルアイコンのみの表示となるため、数多くのパネルを閉じた場合、どのアイコンがどのパネルに該当するのか判別し難くなることがあります。
このような場合、ヘッダのタイトル部分も表示されていると、分かりやすくて便利です。
C1SplitContainerでは、パネルの縮小ハンドルをクリックするとVisibleChangedイベントが発生します。なお、すべてのパネルで一つの共通なVisibleChangedイベントを使用した場合、そのsender引数でイベントを発生させたC1SplitterPanelを判別できます。これを利用し、VisibleChangedイベント内で該当するパネルの高さを調整することで、ヘッダのタイトルを表示させたままにすることができます。
以下のサンプルでは、パネル縮小時に、C1SplitterPanelのCollapsedをTrueに、MinHeightをゼロに、Heightをヘッダタイトルの高さに設定することで、この動作を実現する例を紹介しています。
※C1SplitterPanels_VisibleChangedは、設計画面にて、C1SplitterPanel1~C1SplitterPanel4のすべてのVisibleChangedイベントに割り当てておきます。
◎サンプルコード(VB)
◎サンプルコード(C#)
このような場合、ヘッダのタイトル部分も表示されていると、分かりやすくて便利です。
C1SplitContainerでは、パネルの縮小ハンドルをクリックするとVisibleChangedイベントが発生します。なお、すべてのパネルで一つの共通なVisibleChangedイベントを使用した場合、そのsender引数でイベントを発生させたC1SplitterPanelを判別できます。これを利用し、VisibleChangedイベント内で該当するパネルの高さを調整することで、ヘッダのタイトルを表示させたままにすることができます。
以下のサンプルでは、パネル縮小時に、C1SplitterPanelのCollapsedをTrueに、MinHeightをゼロに、Heightをヘッダタイトルの高さに設定することで、この動作を実現する例を紹介しています。
※C1SplitterPanels_VisibleChangedは、設計画面にて、C1SplitterPanel1~C1SplitterPanel4のすべてのVisibleChangedイベントに割り当てておきます。
◎サンプルコード(VB)
Imports C1.Win.C1SplitContainer
Public Class Form1
Dim mhSP As Dictionary(Of Control, Integer)
Dim hSP As Dictionary(Of Control, Integer)
Dim bLoad As Dictionary(Of Control, Boolean)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'ヘッダタイトルのツールチップを設定します
C1SplitterPanel1.CollapsingToolTip = "このパネルには何も含まれません"
C1SplitterPanel2.CollapsingToolTip = "このパネルにはLabelとTextBoxが含まれます"
C1SplitterPanel3.CollapsingToolTip = "このパネルには何も含まれません"
C1SplitterPanel4.CollapsingToolTip = "このパネルには何も含まれません"
'縮小ハンドルに大きなアイコンを表示します
C1SplitContainer1.EnlargeCollapsingHandle = True
'初期値を設定します
mhSP = New Dictionary(Of Control, Integer)
hSP = New Dictionary(Of Control, Integer)
bLoad = New Dictionary(Of Control, Boolean)
For Each p In C1SplitContainer1.Panels
mhSP(p) = p.MinHeight
hSP(p) = p.Height
bLoad(p) = True
Next
End Sub
Private Sub C1SplitterPanels_VisibleChanged(sender As Object, e As EventArgs) Handles C1SplitterPanel3.VisibleChanged, C1SplitterPanel2.VisibleChanged, C1SplitterPanel1.VisibleChanged
Dim p = DirectCast(sender, C1SplitterPanel)
If bLoad(p) = True Then
bLoad(p) = False
Else
If p.Height < 35 Then
p.Collapsed = True
p.MinHeight = mhSP(p)
p.Height = hSP(p)
Else
p.Collapsed = True
p.MinHeight = 0
p.Height = 25
End If
End If
End Sub
End Class
Public Class Form1
Dim mhSP As Dictionary(Of Control, Integer)
Dim hSP As Dictionary(Of Control, Integer)
Dim bLoad As Dictionary(Of Control, Boolean)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'ヘッダタイトルのツールチップを設定します
C1SplitterPanel1.CollapsingToolTip = "このパネルには何も含まれません"
C1SplitterPanel2.CollapsingToolTip = "このパネルにはLabelとTextBoxが含まれます"
C1SplitterPanel3.CollapsingToolTip = "このパネルには何も含まれません"
C1SplitterPanel4.CollapsingToolTip = "このパネルには何も含まれません"
'縮小ハンドルに大きなアイコンを表示します
C1SplitContainer1.EnlargeCollapsingHandle = True
'初期値を設定します
mhSP = New Dictionary(Of Control, Integer)
hSP = New Dictionary(Of Control, Integer)
bLoad = New Dictionary(Of Control, Boolean)
For Each p In C1SplitContainer1.Panels
mhSP(p) = p.MinHeight
hSP(p) = p.Height
bLoad(p) = True
Next
End Sub
Private Sub C1SplitterPanels_VisibleChanged(sender As Object, e As EventArgs) Handles C1SplitterPanel3.VisibleChanged, C1SplitterPanel2.VisibleChanged, C1SplitterPanel1.VisibleChanged
Dim p = DirectCast(sender, C1SplitterPanel)
If bLoad(p) = True Then
bLoad(p) = False
Else
If p.Height < 35 Then
p.Collapsed = True
p.MinHeight = mhSP(p)
p.Height = hSP(p)
Else
p.Collapsed = True
p.MinHeight = 0
p.Height = 25
End If
End If
End Sub
End Class
◎サンプルコード(C#)
using C1.Win.C1SplitContainer;
namespace prj_SplitContainer
{
public partial class Form1 : Form
{
Dictionary mhSP;
Dictionary hSP;
Dictionary bLoad;
public Form1()
{
InitializeComponent();
// フォームロード前に発生するc1SplitterPanels_VisibleChangedイベントで、
// 判別に使用されるbLoad[p]を、null以外に設定しておきます。
bLoad = new Dictionary();
foreach (C1SplitterPanel p in c1SplitContainer1.Panels)
{
bLoad[p] = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
// ヘッダタイトルのツールチップを設定します
c1SplitterPanel1.CollapsingToolTip = "このパネルには何も含まれません";
c1SplitterPanel2.CollapsingToolTip = "このパネルにはLabelとTextBoxが含まれます";
c1SplitterPanel3.CollapsingToolTip = "このパネルには何も含まれません";
c1SplitterPanel4.CollapsingToolTip = "このパネルには何も含まれません";
c1SplitContainer1.EnlargeCollapsingHandle = true;
mhSP = new Dictionary();
hSP = new Dictionary();
bLoad = new Dictionary();
foreach (C1SplitterPanel p in c1SplitContainer1.Panels)
{
mhSP[p] = p.MinHeight;
hSP[p] = p.Height;
bLoad[p] = true;
}
}
private void c1SplitterPanels_VisibleChanged(object sender, EventArgs e)
{
C1SplitterPanel p = sender as C1SplitterPanel;
if (bLoad[p] == true)
{
bLoad[p] = false;
}
else
{
if ((p.Height < 35))
{
p.Collapsed = true;
p.MinHeight = mhSP[p];
p.Height = hSP[p];
}
else
{
p.Collapsed = true;
p.MinHeight = 0;
p.Height = 25;
}
}
}
}
}
namespace prj_SplitContainer
{
public partial class Form1 : Form
{
Dictionary
Dictionary
Dictionary
public Form1()
{
InitializeComponent();
// フォームロード前に発生するc1SplitterPanels_VisibleChangedイベントで、
// 判別に使用されるbLoad[p]を、null以外に設定しておきます。
bLoad = new Dictionary
foreach (C1SplitterPanel p in c1SplitContainer1.Panels)
{
bLoad[p] = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
// ヘッダタイトルのツールチップを設定します
c1SplitterPanel1.CollapsingToolTip = "このパネルには何も含まれません";
c1SplitterPanel2.CollapsingToolTip = "このパネルにはLabelとTextBoxが含まれます";
c1SplitterPanel3.CollapsingToolTip = "このパネルには何も含まれません";
c1SplitterPanel4.CollapsingToolTip = "このパネルには何も含まれません";
c1SplitContainer1.EnlargeCollapsingHandle = true;
mhSP = new Dictionary
hSP = new Dictionary
bLoad = new Dictionary
foreach (C1SplitterPanel p in c1SplitContainer1.Panels)
{
mhSP[p] = p.MinHeight;
hSP[p] = p.Height;
bLoad[p] = true;
}
}
private void c1SplitterPanels_VisibleChanged(object sender, EventArgs e)
{
C1SplitterPanel p = sender as C1SplitterPanel;
if (bLoad[p] == true)
{
bLoad[p] = false;
}
else
{
if ((p.Height < 35))
{
p.Collapsed = true;
p.MinHeight = mhSP[p];
p.Height = hSP[p];
}
else
{
p.Collapsed = true;
p.MinHeight = 0;
p.Height = 25;
}
}
}
}
}
旧文書番号
83555