Windows Develop Bookmark and Share   
 index > Windows Forms General > DatagridView Disable a Checkbox with a Tick In
 

DatagridView Disable a Checkbox with a Tick In

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 stored 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
  • Moved byTaylorMichaelLMVPWednesday, September 30, 2009 2:02 PMWinForms related (From:Visual C# General)
  •  
Ismailc  Wednesday, September 30, 2009 10:36 AM

Hi,

 

DataGridView does not have built-in support for disabling a cell. We can change the Visual Cue that it is disabled.

Please refer to this FAQ:

15.How do I disable a cell?

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b87513747e#faq15

 

By the way, if you don’t want user to check the checkbox, you can set the readonly property to true.

 

Here is example shows Disable CheckBoxcolumn. Hope this helps.

How to: Disable CheckBoxes in a CheckBox Column in the Windows Forms DataGridView Control

http://social.msdn.microsoft.com/Forums/en/winformsdatacontrols/thread/988c7e3f-c172-467d-89b7-b80a60b7f24f

 

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, October 05, 2009 9:19 AM

Hi,

 

DataGridView does not have built-in support for disabling a cell. We can change the Visual Cue that it is disabled.

Please refer to this FAQ:

15.How do I disable a cell?

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b87513747e#faq15

 

By the way, if you don’t want user to check the checkbox, you can set the readonly property to true.

 

Here is example shows Disable CheckBoxcolumn. Hope this helps.

How to: Disable CheckBoxes in a CheckBox Column in the Windows Forms DataGridView Control

http://social.msdn.microsoft.com/Forums/en/winformsdatacontrols/thread/988c7e3f-c172-467d-89b7-b80a60b7f24f

 

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, October 05, 2009 9:19 AM

You can use google to search for other answers

Custom Search

More Threads

• C# Passing Values To and Fro Form using EventArgs
• Using tab control
• MDIChild Menu problem...
• draw graphics within groupbox
• Label and other control overlap when Label.AutoSize set to true
• CheckedChanged on load
• Two ComboBoxes with parent / child relation inside a datagrid - C# 2005
• WinForm default size
• Command Line Args
• While creating resource file programetically throws Exception.