For Each c In Me.DataGridView1.Columns
c.SortMode = DataGridViewColumnSortMode.NotSortable
Next
This is the DataGridView handler you need to capture the button click event.
this.dgvList.CellContentClick += new DataGridViewCellEventHandler(DGV_CellContentClick);
This is the button click handler example
#region DGV_CellContentClick
public void DGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int selectedRowIndex = int.Parse(e.RowIndex.ToString());
if (this.dgvList.Columns[e.ColumnIndex] == buttonColumn && selectedRowIndex >= 0)
{
DataRow dr = DataGridViewHelper.GetDataRow(this.dgvList);
MessageBox.Show((string)dr["FirstName"]);
}
}
Read More »
c.SortMode = DataGridViewColumnSortMode.NotSortable
Next
This is the DataGridView handler you need to capture the button click event.
this.dgvList.CellContentClick += new DataGridViewCellEventHandler(DGV_CellContentClick);
This is the button click handler example
#region DGV_CellContentClick
public void DGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int selectedRowIndex = int.Parse(e.RowIndex.ToString());
if (this.dgvList.Columns[e.ColumnIndex] == buttonColumn && selectedRowIndex >= 0)
{
DataRow dr = DataGridViewHelper.GetDataRow(this.dgvList);
MessageBox.Show((string)dr["FirstName"]);
}
}