Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi to all

i have google this topic but can't find any good tutorial to solve my answer . please tell me

" How to add a button with in a GridView using C# on Window Application "
Posted

Hi Aeslan,

Please use following code:

C#
DataGridViewButtonColumn dgbtnAdd = new DataGridViewButtonColumn();
                dgbtnAdd.Text = "Add new";
                dgvCustomer.Columns.Add(dgbtnAdd);



Please do let me know, if you have any doubt.

Please provide Vote if this would be helpful to you.

Thanks,
Imdadhusen
 
Share this answer
 
You Can Add Button in a Grid View by using two way

Fisrt Way is greatly present by Sunasara Imdadhusen
Second Way is that you can use Insert Method instead of ADD Method.

DataGridViewButtonColumn obj = new DataGridViewButtonColumn();
obj.Text = "First";
obj.DisplayIndex = 0; // For First Index
dataGridView1.Columns.Insert(0, obj);

obj = new DataGridViewButtonColumn(); // New initialisation
obj.Text = "Second";
obj.DisplayIndex = 1; // For Second Index
dataGridView1.Columns.Insert(1, obj);

// and So on...
 
Share this answer
 
Hi All,

I would like to add text data in datagridview by programatically in c# window application.

Please let me know the code snippet for the same..

Thanks,
Sudheer
 
Share this answer
 
but where can i put this code please guide me whether i put this code in a gridview ?
 
Share this answer
 
Comments
T.Saravanann 17-Sep-10 7:40am    
After bind your grid put this code.
arslan3488 17-Sep-10 7:51am    
thanks you very much sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900