これは私のデータグリッドビューのビューです..
これは翻訳ボタンで、クリックすると横に新しい行が表示され、その行で新しいボタンも初期化されます。
今私が欲しいのは、翻訳ボタンがクリックされた場合、表示される新しい行に翻訳ボタンが含まれていないことです..ボタンを動的に初期化しました..これが私のコードです。
private void button()
{
var buttonCol = new DataGridViewButtonColumn();
buttonCol.Name = "ButtonColumnName";
buttonCol.HeaderText = "Header";
buttonCol.Text = "Translate";
buttonCol.Name = "Edit";
buttonCol.Width = 30;
buttonCol.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(buttonCol);
}
ボタンがクリックされたときのイベントです。
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// button();
Column_handling();
if (e.ColumnIndex == 10)
{
DataRow dt = datarows.NewRow();
dt[0] = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
dt[1] = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
dt[2] = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
dt[3] = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
dt[4] = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
dt[5] = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
dt[6] = this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
dt[7] = this.dataGridView1.CurrentRow.Cells[7].Value.ToString();
dt[8] = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
dt[9] = this.dataGridView1.CurrentRow.Cells[9].Value.ToString();
datarows.Rows.InsertAt(dt, e.RowIndex+1);
dataGridView1.Refresh();
}
何か案は?