|
■No99235 (nyohhiroki さん) に返信 > CommitEdit()を使えば、強制的にコミット出来るかと考えたのですが、 > 上手くいかず[IsCurrentRowDirty]がどうしてもTrueになってしまいます。
private DataGridViewButtonColumn CopyBtnColumn; private DataTable DT1; private void Form1_Load(object sender, EventArgs e) { this.DT1 = new DataTable("DT1"); this.DT1.Columns.Add("Col1"); this.DT1.Columns.Add("Col2"); this.dataGridTest.DataSource = this.DT1; this.dataGridTest.Columns.Insert(0, this.CopyBtnColumn = new DataGridViewButtonColumn()); this.CopyBtnColumn.UseColumnTextForButtonValue = true; this.CopyBtnColumn.Text = "TEST"; this.CopyBtnColumn.Name = "TEST"; }
private void dataGridTest_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == this.CopyBtnColumn.Index) { var rowView = ((DataGridView)sender).Rows[e.RowIndex].DataBoundItem as DataRowView; if (rowView == null) { this.label1.Text = ""; } else { rowView.EndEdit(); // ★
string[] lines = { "Dirty:" + ((DataGridView)sender).IsCurrentRowDirty, "RowState:" + rowView.Row.RowState, "Col1:" + rowView["Col1"], "Col2:" + rowView["Col2"] }; this.label1.Text = string.Join("\r\n", lines); } } }
|