作成日: 2022/03/11 最終更新日: 2022/03/30
文書種別
使用方法
詳細
CellEditedFormattedValueChangedイベントでEditingActions.CancelEditを実行して編集操作を取り消したあと、目的の値を設定することで実現することができます。
[Visual Basic]
[C#]
[Visual Basic]
Imports GrapeCity.Win.MultiRow
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim checkBoxCell1 As New CheckBoxCell()
checkBoxCell1.Name = "checkBoxCell1"
Dim textBoxCell1 As New TextBoxCell()
textBoxCell1.Name = "textBoxCell1"
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {checkBoxCell1, textBoxCell1})
GcMultiRow1.RowCount = 5
End Sub
Private Sub GcMultiRow1_CellEditedFormattedValueChanged(sender As System.Object, e As CellEditedFormattedValueChangedEventArgs) Handles GcMultiRow1.CellEditedFormattedValueChanged
If e.CellName = "checkBoxCell1" Then
Dim check As String = GcMultiRow1.GetValue(e.RowIndex, "textBoxCell1")
If check = "a" Then
' textBoxCell1に"a"が設定されていたら、checkBoxCell1をOFFにする
EditingActions.CancelEdit.Execute(GcMultiRow1)
GcMultiRow1.CurrentCell.Value = False
End If
End If
End Sub
[C#]
using GrapeCity.Win.MultiRow;
private void Form1_Load(object sender, EventArgs e)
{
CheckBoxCell checkBoxCell1 = new CheckBoxCell();
checkBoxCell1.Name = "checkBoxCell1";
TextBoxCell textBoxCell1 = new TextBoxCell();
textBoxCell1.Name = "textBoxCell1";
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] {checkBoxCell1, textBoxCell1});
gcMultiRow1.RowCount = 5;
}
private void gcMultiRow1_CellEditedFormattedValueChanged(object sender, CellEditedFormattedValueChangedEventArgs e)
{
if (e.CellName == "checkBoxCell1")
{
string check = (string)gcMultiRow1.GetValue(e.RowIndex, "textBoxCell1");
if (check == "a")
{
// textBoxCell1に"a"が設定されていたら、checkBoxCell1をOFFにする
EditingActions.CancelEdit.Execute(gcMultiRow1);
gcMultiRow1.CurrentCell.Value = false;
}
}
}