リサイズコンポーネントでGcListBoxのリサイズ時に発生する問題を回避するリサイズポリシー
対象製品
PlusPak for Windows Forms 7.0J
詳細
リサイズコンポーネント(GcResize)を使用して、InputManのGcListBoxコントロールをリサイズする場合、下記の問題が発生します。
本現象は、以下のコードを使用してユーザー定義のリサイズポリシーを追加することで対応できます。
なお、本現象はリサイズパネル(GcResizePanel)でも発生しますが、同じ方法で対応できます。
ユーザー定義のリサイズポリシーの使い方については、製品ヘルプの以下の内容をご参照ください。
PowerTools PlusPak for Windows Forms 7.0J
- PlusPak の使い方
- レイアウト
- GcResize コンポーネント
- リサイズポリシー
- リストの列幅がコントロールに合わせてサイズ変更されない
本現象は、以下のコードを使用してユーザー定義のリサイズポリシーを追加することで対応できます。
なお、本現象はリサイズパネル(GcResizePanel)でも発生しますが、同じ方法で対応できます。
ユーザー定義のリサイズポリシーの使い方については、製品ヘルプの以下の内容をご参照ください。
PowerTools PlusPak for Windows Forms 7.0J
- PlusPak の使い方
- レイアウト
- GcResize コンポーネント
- リサイズポリシー
[Visual Basic]
Imports GrapeCity.Win.Components
Imports GrapeCity.Win.Editors
Public Class InputManListBoxResizePolicy
Inherits ResizePolicy
Public Overrides ReadOnly Property TargetType() As Type
Get
Return GetType(GcListBox)
End Get
End Property
Public Overrides Sub ResizeLayout(control As Control, infos As ResizeLayoutInfo)
Try
Dim listBox As GcListBox = TryCast(control, GcListBox)
If listBox IsNot Nothing AndAlso listBox.Columns IsNot Nothing Then
' change all columns' width.
For Each column As ListColumn In listBox.Columns
Dim oldWidth As Integer = column.Width
column.Width = infos.ScaleX(oldWidth)
Next
End If
Catch
End Try
MyBase.ResizeLayout(control, infos)
End Sub
End Class
Imports GrapeCity.Win.Components
Imports GrapeCity.Win.Editors
Public Class InputManListBoxResizePolicy
Inherits ResizePolicy
Public Overrides ReadOnly Property TargetType() As Type
Get
Return GetType(GcListBox)
End Get
End Property
Public Overrides Sub ResizeLayout(control As Control, infos As ResizeLayoutInfo)
Try
Dim listBox As GcListBox = TryCast(control, GcListBox)
If listBox IsNot Nothing AndAlso listBox.Columns IsNot Nothing Then
' change all columns' width.
For Each column As ListColumn In listBox.Columns
Dim oldWidth As Integer = column.Width
column.Width = infos.ScaleX(oldWidth)
Next
End If
Catch
End Try
MyBase.ResizeLayout(control, infos)
End Sub
End Class
[C#]
using GrapeCity.Win.Components;
using GrapeCity.Win.Editors;
public class InputManListBoxResizePolicy : ResizePolicy
{
public override Type TargetType
{
get { return typeof(GcListBox); }
}
public override void ResizeLayout(Control control, ResizeLayoutInfo infos)
{
try
{
GcListBox listBox = control as GcListBox;
if (listBox != null && listBox.Columns != null)
{
// change all columns' width.
foreach (ListColumn column in listBox.Columns)
{
int oldWidth = column.Width;
column.Width = infos.ScaleX(oldWidth);
}
}
}
catch
{
}
base.ResizeLayout(control, infos);
}
}
using GrapeCity.Win.Components;
using GrapeCity.Win.Editors;
public class InputManListBoxResizePolicy : ResizePolicy
{
public override Type TargetType
{
get { return typeof(GcListBox); }
}
public override void ResizeLayout(Control control, ResizeLayoutInfo infos)
{
try
{
GcListBox listBox = control as GcListBox;
if (listBox != null && listBox.Columns != null)
{
// change all columns' width.
foreach (ListColumn column in listBox.Columns)
{
int oldWidth = column.Width;
column.Width = infos.ScaleX(oldWidth);
}
}
}
catch
{
}
base.ResizeLayout(control, infos);
}
}