Share via


How to increase the size of Checkbox in DataGridViewCheckBoxCell

Question

Friday, June 24, 2011 10:40 AM

Hi everyone,

 

Can someone tell me if it is possible to increase the size of Checkbox in DataGridViewCheckBoxCell?

 

Thank you in advance for any help.

CardSpace

All replies (5)

Monday, June 27, 2011 12:58 PM ✅Answered

The DataGridViewCheckBoxCell is a CheckBox hosted component, both of them are not support changing size.

 

If you want a sizable CheckBox, you can choose WPF and use the CheckBox Styles and Templates to change its size.

And you also can use WPF control in your Windows Form:

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

 

Or you can draw a rectangle as the CheckBox, and then draw any icon as the CheckBox checked mark:

http://msdn.microsoft.com/en-us/library/32t0cdd6.aspx

After you customize the CheckBox, then you will need to host it into the DataGridView cell:

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

 

And you also can draw two images(PS CheckBox), one is checked, and another is unchecked, then you can display it in the cells as a big size CheckBox, then you also need a variable to record this cell's value when you click on it or others modification. I think you can use this idea on a custom control, and then host it into the cells.

But it will take to you more questions if you customize it, you need to rewrite a data bound codes and anyothers event code.

So I don't suggest you customize it, and I suggest you use the original one.

Best wishes,

Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Wednesday, June 29, 2011 11:48 AM ✅Answered

No, you do not need to replace all your others controls.

You only need to host the WPF controls in the cell in Windows Form project. You can ref the link I provided to understand this host proceed.

It is like that, we don't want button1, and want use WPF control replace it, then we just need to replace this button1, the others will not relate to this request.

As I mentioned, it would be a hard road to customize the ComboBox, not say related to the DataGridView control. You will need more knowledge about DataBinding and control host.

Any way, good luck! After you finished this function, I think you will be closed the senor expert.

 

Best wishes,

Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Friday, June 24, 2011 11:40 AM

Hi,

 

You need to override the Paint() method of the DataGridViewCombobBoxCell  or DataGridViewCheckBoxCell in order to change the size.

Refer the following link for a sample code.

How to change size of combobox/Checkbox in DataGridViewComboBoxCell/DataGridViewCheckBoxCell

Microsoft MVP - ASP/ASP.NET


Friday, June 24, 2011 1:58 PM

Hi Ramesh,

 

Thank you for your answer. I was reading this link before, but unfortunately the code provided in this link doesn't increase the size of the checkbox.

 

Could you please tell me which code I should write in the Paint method to increase the size of the checkbox? 

 

Thank you

CardSpace


Wednesday, June 29, 2011 8:49 AM

Hi Mike, thank you for your reply. I am going to have a look the controls in WPF and decide if I want to use this technology or customize the CheckBox.

In the case that I decide to use WPF, do I need to replace all my current controls in Winforms?

Thank you again for your help

CardSpace