동적으로 생성 된 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???
}
도움을 주셔서 감사합니다.
데이비드.
정말 감사합니다, 매우 도움이! –