{
dataGridView1.ColumnCount = 2;
dataGridView1.Columns[0].Name = "EID";
dataGridView1.Columns[1].Name = "NAME";
for (int i = 0; i < dt.Rows.Count; i++)
{
string[] r = new string[] { dt.Rows[i].ItemArray[0].ToString(),dt.Rows[i].ItemArray[1].ToString()
};
dataGridView1.Rows.Add(r);
}
DataGridViewButtonColumn dgb = new DataGridViewButtonColumn();
dgb.HeaderText = "Press Me";
dgb.Text = "Save";
dgb.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(dgb);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(e.ColumnIndex==2)
MessageBox.Show(dataGridView1.CurrentRow.Cells[1].Value.ToString());
}
dataGridView1.ColumnCount = 2;
dataGridView1.Columns[0].Name = "EID";
dataGridView1.Columns[1].Name = "NAME";
for (int i = 0; i < dt.Rows.Count; i++)
{
string[] r = new string[] { dt.Rows[i].ItemArray[0].ToString(),dt.Rows[i].ItemArray[1].ToString()
};
dataGridView1.Rows.Add(r);
}
DataGridViewButtonColumn dgb = new DataGridViewButtonColumn();
dgb.HeaderText = "Press Me";
dgb.Text = "Save";
dgb.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(dgb);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(e.ColumnIndex==2)
MessageBox.Show(dataGridView1.CurrentRow.Cells[1].Value.ToString());
}
No comments:
Post a Comment