作成日: 2024/01/31 最終更新日: 2024/01/31
文書種別
使用方法
詳細
GcMultiRow.FirstDisplayedCellPositionプロパティを使用して、GcMultiRowコントロールに表示されている最初のセルの位置を取得し、その情報とGcMultiRowコントロール上に表示されている行、セルから算出することができます。
※下記のサンプルコードは完全に表示されているセルではなく、右下の端に少しでも表示されているセルが対象となります。
[Visual Basic]
[C#]
※下記のサンプルコードは完全に表示されているセルではなく、右下の端に少しでも表示されているセルが対象となります。
[Visual Basic]
Imports GrapeCity.Win.MultiRow
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim topRow As Integer = GcMultiRow1.FirstDisplayedCellPosition.RowIndex
Dim bottomRow As Integer = topRow
Dim cellXpos As Integer = 0
Dim cellYpos As Integer = 0
Dim cellIndex As Integer = 0
Dim rowIndex As Integer = 0
' グリッド上に表示されている右端のセルのCellIndexを取得する
For leftCell As Integer = 0 To GcMultiRow1.Rows(bottomRow).Cells.Count - 1
If GcMultiRow1.Rows(bottomRow).Cells(leftCell).Displayed Then
' Xの値により右端に表示されているセルを判別する
If cellXpos <= GcMultiRow1.Rows(bottomRow).Cells(leftCell).Location.X Then
cellXpos = GcMultiRow1.Rows(bottomRow).Cells(leftCell).Location.X
' Xの値が同じ場合、Yの値により下部に表示されているセルを判別する
If cellYpos <= GcMultiRow1.Rows(bottomRow).Cells(leftCell).Location.Y Then
cellYpos = GcMultiRow1.Rows(bottomRow).Cells(leftCell).Location.Y
cellIndex = GcMultiRow1.Rows(bottomRow).Cells(leftCell).CellIndex
End If
End If
End If
Next
' グリッド上に表示されてい最下部の行のRowIndexを取得する
While GcMultiRow1.Rows(bottomRow).Displayed And bottomRow < GcMultiRow1.RowCount - 1
rowIndex = GcMultiRow1.Rows(bottomRow).Index
bottomRow += 1
End While
Console.WriteLine("rowIndex:{0}, cellIndex:{1}", rowIndex, cellIndex)
End Sub
[C#]
using GrapeCity.Win.MultiRow;
private void button1_Click(object sender, EventArgs e)
{
int topRow = gcMultiRow1.FirstDisplayedCellPosition.RowIndex;
int bottomRow = topRow;
int cellXpos = 0;
int cellYpos = 0;
int cellIndex = 0;
int rowIndex = 0;
// グリッド上に表示されている右端のセルのCellIndexを取得する
for (int leftCell = 0; leftCell < gcMultiRow1.Rows[bottomRow].Cells.Count; leftCell++ )
{
if (gcMultiRow1.Rows[bottomRow].Cells[leftCell].Displayed)
{
// Xの値により右端に表示されているセルを判別する
if (cellXpos <= gcMultiRow1.Rows[bottomRow].Cells[leftCell].Location.X)
{
cellXpos = gcMultiRow1.Rows[bottomRow].Cells[leftCell].Location.X;
// Xの値が同じ場合、Yの値により下部に表示されているセルを判別する
if (cellYpos <= gcMultiRow1.Rows[bottomRow].Cells[leftCell].Location.Y)
{
cellYpos = gcMultiRow1.Rows[bottomRow].Cells[leftCell].Location.Y;
cellIndex = gcMultiRow1.Rows[bottomRow].Cells[leftCell].CellIndex;
}
}
}
}
// グリッド上に表示されてい最下部の行のRowIndexを取得する
while (gcMultiRow1.Rows[bottomRow].Displayed && bottomRow < gcMultiRow1.RowCount -1)
{
rowIndex = gcMultiRow1.Rows[bottomRow].Index;
bottomRow += 1;
}
Console.WriteLine("rowIndex:{0}, cellIndex:{1}", rowIndex, cellIndex);
}