Windows Develop Bookmark and Share   
 index > Windows Forms General > Sizing buttons in buttoncolumn in DataGridView
 

Sizing buttons in buttoncolumn in DataGridView

Is it possible to have a button column in a DataGridView that has its buttons sized smaller than the cell that the button is in? that is, I want the button to be smaller than the cell that it is in.

Thanks

EM
ExcelMonkey  Sunday, January 13, 2008 4:15 AM

Hi, ExcelMonkey,

Based on my understanding ,you want the Buttons in your DataGridViewButtonColumn smaller than the cell, don't you?

I think you can set the Padding style of the DefaultCellStyle.

For example

Code Block

DataTable datatable = new DataTable();

datatable.Columns.Add("col1");

datatable.Columns.Add("col2");

datatable.Rows.Add("ABC", "bcd");

datatable.Rows.Add("bcd", "ABC");

dataGridView1.DataSource = datatable;

DataGridViewButtonColumn column = new DataGridViewButtonColumn();

column.Width = 100;

column.DefaultCellStyle.Padding = new Padding(5);

dataGridView1.Columns.Add(column);

More info

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.defaultcellstyle.aspx

Hope this helps,

Regards

Yu Guo â€?MSFT  Thursday, January 17, 2008 2:45 AM

Hi, ExcelMonkey,

Based on my understanding ,you want the Buttons in your DataGridViewButtonColumn smaller than the cell, don't you?

I think you can set the Padding style of the DefaultCellStyle.

For example

Code Block

DataTable datatable = new DataTable();

datatable.Columns.Add("col1");

datatable.Columns.Add("col2");

datatable.Rows.Add("ABC", "bcd");

datatable.Rows.Add("bcd", "ABC");

dataGridView1.DataSource = datatable;

DataGridViewButtonColumn column = new DataGridViewButtonColumn();

column.Width = 100;

column.DefaultCellStyle.Padding = new Padding(5);

dataGridView1.Columns.Add(column);

More info

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.defaultcellstyle.aspx

Hope this helps,

Regards

Yu Guo â€?MSFT  Thursday, January 17, 2008 2:45 AM

You can use google to search for other answers

Custom Search

More Threads

• Form 1 being updated by form 2
• How to make Threaded Class ?
• Weird error
• textproblem
• How to save the modified (run-time) content from webbrowser control.
• Greyed-out class members in Object Browser?
• Running a nested message loop
• Read line to line in an array from an textbox
• Controls flicker (strange)
• multiline datagridview cells?