Adding Button in DataGrid RunTime

How to add button in datagird see:-

Create a instance/object of  DataGridViewButtonColumn Class then

Initialize in COnstructor

and do that code shows below:

like if we have a object like this DataGridViewButtonColumn dgbtn;

in COnstructor:

dgbtn=new DataGridViewButtonColumn();

dgbtn.HeaderText="Demo";

dgbtn.Text="Click Me";

dgbtn.UseColumnTextForButtonValue=true;

dgbtn.Width=60;

//demodatagrid object or instance of datagrid.

 

demodatagrid.Columns.Add(dgbtn);

 

Thanks you

If any query so u can contact me thanks you

Next Recommended Reading Drawing a Rectangle at Runtime