リサイズコンポーネントでMultiRowのリサイズ時に発生する問題を回避するリサイズポリシー
対象製品
PlusPak for Windows Forms 7.0J
詳細
リサイズコンポーネント(GcResize)を使用して、GcMultiRowグリッドをリサイズする場合、下記の問題が発生します。
本現象は、以下のコードを使用してユーザー定義のリサイズポリシーを追加することで対応できます。
なお、本現象はリサイズパネル(GcResizePanel)とアプリケーションリサイズ(GcApplicationResize)でも発生しますが、同じ方法で対応できます。
ユーザー定義のリサイズポリシーの使い方については、製品ヘルプの以下の内容をご参照ください。
PowerTools PlusPak for Windows Forms 7.0J
- PlusPak の使い方
- レイアウト
- GcResize コンポーネント
- リサイズポリシー
制限事項
水平か垂直方向の片方のみリサイズしても行の高さと列の幅が同時にサイズ変更します。これはZoomFactorによる動作です。
- グリッドの行と列がコントロールに合わせてサイズ変更されない
本現象は、以下のコードを使用してユーザー定義のリサイズポリシーを追加することで対応できます。
なお、本現象はリサイズパネル(GcResizePanel)とアプリケーションリサイズ(GcApplicationResize)でも発生しますが、同じ方法で対応できます。
ユーザー定義のリサイズポリシーの使い方については、製品ヘルプの以下の内容をご参照ください。
PowerTools PlusPak for Windows Forms 7.0J
- PlusPak の使い方
- レイアウト
- GcResize コンポーネント
- リサイズポリシー
[Visual Basic]
Imports GrapeCity.Win.Components
Imports GrapeCity.Win.MultiRow
Public Class MultiRowResizePolicy
Inherits ResizePolicy
Public Overrides Function CanResizeChildren(control As Control) As Boolean
Return False
End Function
Public Overrides ReadOnly Property TargetType() As Type
Get
Return GetType(GcMultiRow)
End Get
End Property
Public Overrides Sub ResizeLayout(control As Control, infos As ResizeLayoutInfo)
If control Is Nothing Then
Return
End If
MyBase.ResizeLayout(control, infos)
Try
Dim multiRow As GcMultiRow = TryCast(control, GcMultiRow)
If multiRow IsNot Nothing Then
' resize control by control's ZoomFactor.
multiRow.ZoomFactor = CSng(Math.Max(infos.TargetFactorX, infos.TargetFactorY))
End If
Catch generatedExceptionName As Exception
End Try
End Sub
Public Overrides Sub ResizeFont(control As Control, infos As ResizeFontInfo)
control.Font = New Font(control.Font.FontFamily, infos.OriginalFontSize, control.Font.Style, control.Font.Unit, control.Font.GdiCharSet, control.Font.GdiVerticalFont)
End Sub
End Class
Imports GrapeCity.Win.Components
Imports GrapeCity.Win.MultiRow
Public Class MultiRowResizePolicy
Inherits ResizePolicy
Public Overrides Function CanResizeChildren(control As Control) As Boolean
Return False
End Function
Public Overrides ReadOnly Property TargetType() As Type
Get
Return GetType(GcMultiRow)
End Get
End Property
Public Overrides Sub ResizeLayout(control As Control, infos As ResizeLayoutInfo)
If control Is Nothing Then
Return
End If
MyBase.ResizeLayout(control, infos)
Try
Dim multiRow As GcMultiRow = TryCast(control, GcMultiRow)
If multiRow IsNot Nothing Then
' resize control by control's ZoomFactor.
multiRow.ZoomFactor = CSng(Math.Max(infos.TargetFactorX, infos.TargetFactorY))
End If
Catch generatedExceptionName As Exception
End Try
End Sub
Public Overrides Sub ResizeFont(control As Control, infos As ResizeFontInfo)
control.Font = New Font(control.Font.FontFamily, infos.OriginalFontSize, control.Font.Style, control.Font.Unit, control.Font.GdiCharSet, control.Font.GdiVerticalFont)
End Sub
End Class
[C#]
using GrapeCity.Win.Components;
using GrapeCity.Win.MultiRow;
public class MultiRowResizePolicy : ResizePolicy
{
public override bool CanResizeChildren(Control control)
{
return false;
}
public override Type TargetType
{
get { return typeof(GcMultiRow); }
}
public override void ResizeLayout(Control control, ResizeLayoutInfo infos)
{
if (control == null)
{
return;
}
base.ResizeLayout(control, infos);
try
{
GcMultiRow multiRow = control as GcMultiRow;
if (multiRow != null)
{
// resize control by control's ZoomFactor.
multiRow.ZoomFactor = (float)Math.Min(infos.TargetFactorX, infos.TargetFactorY);
}
}
catch (Exception)
{
}
}
public override void ResizeFont(Control control, ResizeFontInfo infos)
{
control.Font = new Font(control.Font.FontFamily, infos.OriginalFontSize, control.Font.Style, control.Font.Unit, control.Font.GdiCharSet, control.Font.GdiVerticalFont);
}
}
using GrapeCity.Win.Components;
using GrapeCity.Win.MultiRow;
public class MultiRowResizePolicy : ResizePolicy
{
public override bool CanResizeChildren(Control control)
{
return false;
}
public override Type TargetType
{
get { return typeof(GcMultiRow); }
}
public override void ResizeLayout(Control control, ResizeLayoutInfo infos)
{
if (control == null)
{
return;
}
base.ResizeLayout(control, infos);
try
{
GcMultiRow multiRow = control as GcMultiRow;
if (multiRow != null)
{
// resize control by control's ZoomFactor.
multiRow.ZoomFactor = (float)Math.Min(infos.TargetFactorX, infos.TargetFactorY);
}
}
catch (Exception)
{
}
}
public override void ResizeFont(Control control, ResizeFontInfo infos)
{
control.Font = new Font(control.Font.FontFamily, infos.OriginalFontSize, control.Font.Style, control.Font.Unit, control.Font.GdiCharSet, control.Font.GdiVerticalFont);
}
}
制限事項
水平か垂直方向の片方のみリサイズしても行の高さと列の幅が同時にサイズ変更します。これはZoomFactorによる動作です。