作成日: 2026/06/24 最終更新日: 2026/06/24
文書種別
使用方法
詳細
SelectedRangesプロパティで選択範囲を取得し、各セルに対して値を設定します。
下記のサンプルコードは、チェックボックス型セルの値をキーイベントを使用して設定する場合の例になります。
◎サンプルコード(VB)
下記のサンプルコードは、チェックボックス型セルの値をキーイベントを使用して設定する場合の例になります。
◎サンプルコード(VB)
Imports GrapeCity.Windows.SpreadGrid Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) Dim chk As New CheckBoxCellType() chk.IndeterminateContent = "保留" chk.TrueContent = "承認" chk.FalseContent = "却下" GcSpreadGrid1.Columns(1).CellType = chk End Sub Private Sub GcSpreadGrid1_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles GcSpreadGrid1.PreviewKeyDown If e.Key = Key.F1 Then For Each cr As CellRange In GcSpreadGrid1.SelectedRanges For i As Integer = 0 To cr.RowCount - 1 GcSpreadGrid1(cr.Row + i, 1).Value = True Next Next End If End Sub◎サンプルコード(C#)
using GrapeCity.Windows.SpreadGrid;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CheckBoxCellType chk = new CheckBoxCellType();
chk.IndeterminateContent = "保留";
chk.TrueContent = "承認";
chk.FalseContent = "却下";
GcSpreadGrid1.Columns[1].CellType = chk;
}
private void GcSpreadGrid1_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.F1)
{
foreach (CellRange cr in GcSpreadGrid1.SelectedRanges)
{
for (int i = 0; i <= (cr.RowCount - 1); i++)
{
GcSpreadGrid1[(cr.Row + i), 1].Value = true;
}
}
}
}