Hi,
I can't seem to make a disabled checkbox in a datagridview with a tick in where the user can't select & stores a value of 0
I got this off the net but it shows a disabled box with no tick in and no value sored in the background as well even more dissapointing
once the mouseover or mousemove between rows the so called disabled checkbox chnages to enable or state.
On the CellPainting Event:
e.PaintBackground(e.CellBounds, true);
Rectangle r = e.CellBounds;
r.Width = 15;
r.Height = 15;
r.X += e.CellBounds.Width / 2 - 8;
r.Y += e.CellBounds.Height / 2 - 8;
ControlPaint.DrawCheckBox(e.Graphics, r, ButtonState.Flat);
e.Handled = true;
Is there no other way?
Please Assist, Regards
Loading
Nir BarPosted Sep 30, 2009, 9:03 AM
There isn't a built-in way. However you can set it's color to grey
dataGridView1.CurrentCell.Style.BackColor = Color.Grey;
Regarding the count - just loop over the rows, and count only those that aren't ReadOnly
Please mark this post as an answer if it helps you
Nir
ic icPosted Oct 1, 2009, 1:51 AM
Nir BarPosted Sep 30, 2009, 10:29 AM
So why not change the back-color of the read-only cells to a different one?
ic icPosted Sep 30, 2009, 10:21 AM
The problem is that when the user activates more checkboxes with backcolor also changing the readonly ones does not stand out visually.
Regards
Nir BarPosted Sep 30, 2009, 10:09 AM
Didn't it do the trick?
Nir
ic icPosted Sep 30, 2009, 9:49 AM
I would have like to have the checkbox looked disabled!
ic icPosted Sep 30, 2009, 8:13 AM
dgvDetail.CurrentRow.Cells[10].Value = 1;
dgvDetail.CurrentRow.Cells[10].ReadOnly = true;
Is there a way of making it disabled?
As well as at the end I roll through table to check for checkbox having a 1 value, how would i exclude the ones i set to readonly from the check?
Please Assis!
Nir BarPosted Sep 30, 2009, 7:37 AM
I'm not sure I got you right:
Do you want the checkbox to be unchecked, and disable changes by the user?
If so, then set FalseValue to 0, Value to 0, and ReadOnly to true (similar properties exist in the column as well, which will apply for all the cells in the column)
If you mean something else, then please clarify
Please mark this post as an answer if it helps you
Nir