CheckBoxCell型セルの値でDataViewのRowFilterを設定している場合、CheckBoxCell型セルの値が変更されたと同時にFilterをかける方法
(2)チェックボックス型セルの値の確定
セル型に関わらず、値を変更した後に他の行をクリックしたときに値が
確定するようになっています。
ご希望の動作にするには、CellEditedFormattedValueChangedイベントで
明示的に値を確定する方法をご検討いただければと存じます。
お手数とは存じますが、下記のサンプルコードをご参考にして
いただければ幸いです。
セル型に関わらず、値を変更した後に他の行をクリックしたときに値が
確定するようになっています。
ご希望の動作にするには、CellEditedFormattedValueChangedイベントで
明示的に値を確定する方法をご検討いただければと存じます。
using System;
using System.Collections.Generic;
using
System.ComponentModel;
using System.Data;
using System.Drawing;
using
System.Linq;
using System.Text;
using System.Windows.Forms;
using
GrapeCity.Win.MultiRow;
namespace M150112002
{
public partial
class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void
Form1_Load(object sender, EventArgs e)
{
//
データの作成
DataTable dt = new DataTable("TEST");
dt.Columns.Add("ColumnA", typeof(Boolean));
dt.Columns.Add("ColumnB", typeof(String));
dt.Rows.Add(false,
"B0");
dt.AcceptChanges();
DataView dv =
dt.DefaultView;
dv.RowFilter = "ColumnA =
'False'";
//dv.RowFilter = "ColumnB = 'B0'";
// セル型の作成
CheckBoxCell checkCell = new
CheckBoxCell();
checkCell.Name = "checkCell";
checkCell.DataField = "ColumnA";
TextBoxCell textCell = new
TextBoxCell();
textCell.Name = "textCell";
textCell.DataField = "ColumnB";
// MulitRowの設定
gcMultiRow1.AllowUserToAddRows = false;
gcMultiRow1.Template =
Template.CreateGridTemplate(new Cell[] { checkCell, textCell });
gcMultiRow1.DataSource = dt;
gcMultiRow1.CellEditedFormattedValueChanged += new
EventHandler<CellEditedFormattedValueChangedEventArgs>(gcMultiRow1_CellEditedFormattedValueChanged);
}
private void gcMultiRow1_CellEditedFormattedValueChanged(object
sender, CellEditedFormattedValueChangedEventArgs e)
{
if (e.CellName == "checkCell")
{
//
変更の確定
gcMultiRow1.EndEdit();
EditingActions.CommitRow.Execute(gcMultiRow1);
}
}
