現在のプログラムが動的に作成されたDataGridViewから情報を取得しようとしています。私は、グリッドに情報を取得し、必要な検索を実行することができましたが、今は本当に立ち往生しています。DataGridViewから動的にデータを取得するC#
各行内にボタンを保持する列をdatagridviewに追加しました。私がしたいのは、クリックされたボタンと同じ行にある列インデックス1のデータの値を取ることです。混乱している?とにかく、コードは次のとおりです:
public void GetValues(...)
{
//Details regarding connection, querying and inserting table
.
.
.
DataGridViewButtonColumn buttonCol = new DataGridViewButtonColumn();
buttonCol.Name = "ButtonColumn";
buttonCol.HeaderText = "Select";
buttonCol.Text = "Edit";
//NB: the text won't show up on the button. Any help there either?
dataGridView1.Columns.Add(buttonCol);
dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);
foreach (DataGridViewRow row in dataGridView1.Rows)
{
DataGridViewButtonCell button = (row.Cells["ButtonColumn"] as DataGridViewButtonCell);
}
dataGridView1.Columns["ButtonColumn"].DisplayIndex = 0;
}
void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
//Here is where I'm having the trouble. What do I put in here???
}
ありがとうございました!
David。
おかげで非常に多く、非常に便利! –