How to create two DataGridViewButtonColumn in just one column?

1.4k views Asked by At

I'm currently working with DataGridView in C# and I find it hard to create two DataGridViewButtonColumn in just one column.

I can only create one DataGridViewButtonColumn in a column by doing :

DataGridViewButtonColumn btnCol = new DataGridViewButtonColumn();
btnCol.Text = "...";
btnCol.UseColumnTextForButtonValue = true;            
DataGridView1.Columns.Add(btnCol);

Is it possible to have two DataGridViewButtonColumn in a single column in DatagridView?

Thanks in advance. :)

1

There are 1 answers

2
Adam Houldsworth On

It is possible, you need to create your own column type. A simple way to achieve this is to create a user control with your two buttons, then use this user control as the editing control on a custom grid column.

There is a good MSDN page about making a calendar column here:

http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

You can use this as a basis for understanding the structure of a custom column, and also to search more accurately on the net for further resources. I've seen someone use this technique to make a custom column that had a DataGridView as its editing control.

Alternatively and much more easily... simply have two button columns next to each other.