作成日: 2017/07/31 最終更新日: 2017/07/31
文書種別
使用方法
詳細
GcSpreadGridクラスのMouseDoubleClickイベントと、HitTestメソッドを使用することで、SPREADがダブルクリックされたときの行や列の情報を取得することができます。
また、ダブルクリックされた箇所がヘッダかセルかなどを区別することも可能です。
◎サンプルコード(VB)
◎サンプルコード(C#)
また、ダブルクリックされた箇所がヘッダかセルかなどを区別することも可能です。
◎サンプルコード(VB)
Private Sub GcSpreadGrid1_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs) Handles GcSpreadGrid1.MouseDoubleClick
Dim hinfo As GrapeCity.Windows.SpreadGrid.HitTestInfo = GcSpreadGrid1.HitTest(e.GetPosition(GcSpreadGrid1))
If TypeOf hinfo Is GrapeCity.Windows.SpreadGrid.CellHitTestInfo Then
Dim cellinfo As GrapeCity.Windows.SpreadGrid.CellHitTestInfo = DirectCast(hinfo, GrapeCity.Windows.SpreadGrid.CellHitTestInfo)
' 行、列がダブルクリックされた情報を取得します。
If cellinfo.RowIndex > -1 Then
Console.WriteLine("インデックス {0} の行がダブルクリックされました", cellinfo.RowIndex)
End If
If cellinfo.ColumnIndex > -1 Then
Console.WriteLine("インデックス {0} の列がダブルクリックされました", cellinfo.ColumnIndex)
End If
' セルまたはヘッダがダブルクリックされたかどうかを取得します。
If cellinfo.Area = GrapeCity.Windows.SpreadGrid.SpreadArea.Cells Then
Console.WriteLine("セルがダブルクリックされました")
ElseIf cellinfo.Area = GrapeCity.Windows.SpreadGrid.SpreadArea.ColumnHeader Then
Console.WriteLine("列ヘッダがダブルクリックされました")
ElseIf cellinfo.Area = GrapeCity.Windows.SpreadGrid.SpreadArea.RowHeader Then
Console.WriteLine("行ヘッダがダブルクリックされました")
End If
End If
End Sub
◎サンプルコード(C#)
public MainWindow()
{
InitializeComponent();
// イベントの関連付け
gcSpreadGrid1.MouseDoubleClick += gcSpreadGrid1_MouseDoubleClick;
}
private void gcSpreadGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
GrapeCity.Windows.SpreadGrid.HitTestInfo hinfo = gcSpreadGrid1.HitTest(e.GetPosition(gcSpreadGrid1));
if (hinfo is GrapeCity.Windows.SpreadGrid.CellHitTestInfo)
{
GrapeCity.Windows.SpreadGrid.CellHitTestInfo cellinfo = (GrapeCity.Windows.SpreadGrid.CellHitTestInfo)hinfo;
// 行、列がダブルクリックされた情報を取得します。
if (cellinfo.RowIndex > -1)
{
Console.WriteLine("インデックス {0} の行がダブルクリックされました", cellinfo.RowIndex);
}
if (cellinfo.ColumnIndex > -1)
{
Console.WriteLine("インデックス {0} の列がダブルクリックされました", cellinfo.ColumnIndex);
}
// セルまたはヘッダがダブルクリックされたかどうかを取得します。
if (cellinfo.Area == GrapeCity.Windows.SpreadGrid.SpreadArea.Cells)
{
Console.WriteLine("セルがダブルクリックされました");
}
else if (cellinfo.Area == GrapeCity.Windows.SpreadGrid.SpreadArea.ColumnHeader)
{
Console.WriteLine("列ヘッダがダブルクリックされました");
}
else if (cellinfo.Area == GrapeCity.Windows.SpreadGrid.SpreadArea.RowHeader)
{
Console.WriteLine("行ヘッダがダブルクリックされました");
}
}
}
関連情報
旧文書番号
40839