作成日: 2022/03/11 最終更新日: 2022/03/30
文書種別
使用方法
詳細
SelectionBackColorプロパティの設定は、セルが非編集状態のときに限って有効になるため、チェックボックス型セルをクリックした直後には背景色は変更されません。
この動作は、明示的にセルのBackColorプロパティを切り替えることで回避することが可能です。
[Visual Basic]
[C#]
この動作は、明示的にセルのBackColorプロパティを切り替えることで回避することが可能です。
[Visual Basic]
Imports GrapeCity.Win.MultiRow
Private Sub InitializeMultiRow()
' セル型の作成
Dim checkCell As New CheckBoxCell()
checkCell.Name = "checkCell"
checkCell.Style.SelectionBackColor = Color.Lavender
checkCell.Style.SelectionForeColor = Color.Blue
Dim textCell As New TextBoxCell()
textCell.Name = "textCell"
textCell.Style.SelectionBackColor = Color.Lavender
textCell.Style.SelectionForeColor = Color.Blue
' MultiRowの設定
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {checkCell, textCell})
GcMultiRow1.RowCount = 5
End Sub
Private Sub GcMultiRow1_CellBeginEdit(ByVal sender As Object, ByVal e As GrapeCity.Win.MultiRow.CellBeginEditEventArgs) Handles GcMultiRow1.CellBeginEdit
' チェックボックス型セルの場合
If TypeOf GcMultiRow1.CurrentCell Is CheckBoxCell Then
' 選択色をセルの色に設定します。
GcMultiRow1.CurrentCell.Style.BackColor = GcMultiRow1.CurrentCell.Style.SelectionBackColor
GcMultiRow1.CurrentCell.Style.ForeColor = GcMultiRow1.CurrentCell.Style.ForeColor
End If
End Sub
Private Sub GcMultiRow1_CellEndEdit(ByVal sender As Object, ByVal e As GrapeCity.Win.MultiRow.CellEndEditEventArgs) Handles GcMultiRow1.CellEndEdit
' チェックボックス型セルの場合
If TypeOf GcMultiRow1.CurrentCell Is CheckBoxCell Then
' セルの色を元に戻します。
GcMultiRow1.CurrentCell.Style.BackColor = Color.Empty
GcMultiRow1.CurrentCell.Style.ForeColor = Color.Empty
End If
End Sub
[C#]
using GrapeCity.Win.MultiRow;
private void InitializeMultiRow()
{
// セル型の作成
CheckBoxCell checkCell = new CheckBoxCell();
checkCell.Name = "checkCell";
checkCell.Style.SelectionBackColor = Color.Lavender;
checkCell.Style.SelectionForeColor = Color.Blue;
TextBoxCell textCell = new TextBoxCell();
textCell.Name = "textCell";
textCell.Style.SelectionBackColor = Color.Lavender;
textCell.Style.SelectionForeColor = Color.Blue;
// MultiRowの設定
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { checkCell, textCell });
gcMultiRow1.RowCount = 5;
gcMultiRow1.CellBeginEdit +=new EventHandler(gcMultiRow1_CellBeginEdit);
gcMultiRow1.CellEndEdit +=new EventHandler(gcMultiRow1_CellEndEdit);
}
private void gcMultiRow1_CellBeginEdit(object sender, CellBeginEditEventArgs e)
{
// チェックボックス型セルの場合
if (gcMultiRow1.CurrentCell is CheckBoxCell)
{
// 選択色をセルの色に設定します。
gcMultiRow1.CurrentCell.Style.BackColor = gcMultiRow1.CurrentCell.Style.SelectionBackColor;
gcMultiRow1.CurrentCell.Style.ForeColor = gcMultiRow1.CurrentCell.Style.ForeColor;
}
}
private void gcMultiRow1_CellEndEdit(object sender, CellEndEditEventArgs e)
{
// チェックボックス型セルの場合
if (gcMultiRow1.CurrentCell is CheckBoxCell)
{
// 選択色をセルの色に設定します。
gcMultiRow1.CurrentCell.Style.BackColor = Color.Empty;
gcMultiRow1.CurrentCell.Style.ForeColor = Color.Empty;
}
}