mardi 30 août 2022

Change checkBox Size of Datagridview Checkbox Cell and increase the clickable area

I have a checkbox column in my .net core Winform data GridVew.
I already made the checkbox bigger to be easier for the user to click.

My code inside CellPainting,

                e.PaintBackground(e.CellBounds, true);
                ControlPaint.DrawCheckBox(e.Graphics, e.CellBounds.X + 1, e.CellBounds.Y + 5,
                    e.CellBounds.Width - 10, e.CellBounds.Height - 10,
                    (bool)e.FormattedValue ? ButtonState.Checked : ButtonState.Normal);
                e.Handled = true;

Those are my reference links,
How to change checkBox Size in DatagridviewCheckboxCell
Increase the size of Checkbox in #DataGridView in C#

The result is like below,

enter image description here

But the problem is the click area, even though the size of the checkbox is bigger, I realize the clickable area is still in its original size.
As I show below, the green area is clickable area,
enter image description here

I want to make the clickable area as big as the checkbox's size as show below,
enter image description here

Is there any solution?




Aucun commentaire:

Enregistrer un commentaire