作成日: 2024/01/31 最終更新日: 2024/01/31
文書種別
技術情報
詳細
CellクラスのLocationプロパティとSizeプロパティは、テンプレート内での位置とサイズを取得・設定するために用意されているものなので、実行時に指定したセルのコントロール上の位置やZoomfactorプロパティで拡大・縮小表示されたサイズなどを取得することはできません。
実行時にセルの位置とサイズを取得するには、GetCellDisplayRectangleメソッドをご利用ください。
サンプルコードを以下にご紹介いたします。
[Visual Basic]
[C#]
実行時にセルの位置とサイズを取得するには、GetCellDisplayRectangleメソッドをご利用ください。
サンプルコードを以下にご紹介いたします。
[Visual Basic]
Imports GrapeCity.Win.MultiRow
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GcMultiRow1.Template = Template.CreateGridTemplate(2)
GcMultiRow1.RowCount = 5
End Sub
Private Sub GcMultiRow1_Resize(sender As Object, e As EventArgs) Handles GcMultiRow1.Resize
If GcMultiRow1.RowCount > 0 Then
Dim rect As Rectangle = GcMultiRow1.GetCellDisplayRectangle(CellScope.Row, 0, 0, 1, 1)
Console.WriteLine("rect: {0}", rect)
Console.WriteLine("location: {0} size: {1}", GcMultiRow1(1, 1).Location, GcMultiRow1(1, 1).Size)
End If
End Sub
End Class
[C#]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
gcMultiRow1.Resize += gcMultiRow1_Resize;
}
private void Form1_Load(object sender, EventArgs e)
{
gcMultiRow1.Template = Template.CreateGridTemplate(2);
gcMultiRow1.RowCount = 5;
}
private void gcMultiRow1_Resize(object sender, EventArgs e)
{
if (gcMultiRow1.RowCount > 0)
{
Rectangle rect = gcMultiRow1.GetCellDisplayRectangle(CellScope.Row, 0, 0, 1, 1);
Console.WriteLine("rect: {0}", rect);
Console.WriteLine("location: {0} size: {1}", gcMultiRow1[1, 1].Location, gcMultiRow1[1, 1].Size);
}
}
}