Add Buttons dynamically in the datagridview windows forms

Rajesh081725
Posted by Rajesh081725 under C# category on | Points: 40 | Views : 5556
Add Column With Button In DataGridView Dynamically
Follow this Code






DataGridViewButtonColumn bcol = new DataGridViewButtonColumn();
bcol.HeaderText = "Button Column ";
bcol.Text = "Click Me";
bcol.Name = "btnClickMe";
bcol.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(bcol);

And For Handling Click Event of Button


private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1)
{

//StateMents you Want to execute to Get Data
}
}

Comments or Responses

Login to post response