Hiding DataGridBoolColumn checkboxes?

  • Thread starter Thread starter Greg Allen
  • Start date Start date
G

Greg Allen

Is there a way to hide a checkbox on a particular row of a column that
is a DataGridBoolColumn?

I need to be able to pick and choose, on a cell by cell basis, whether or
not to display a checkbox. Can I derive from DataGridBoolColumn and
make this happen? If so, how?

Any ideas?

Thanks,

-- Greg
 
Inherit DataGridBoolColumn and override its Paint method
In the cases where you want the checkbox you can simply
call the base class.

You might also want to override the Edit method to prevent
editing (by not calling the base class) of a particular cell.

/claes
 
That works great, except the cells without the checkbox are a different
color. Is there a way to call my own Paint method in this case to color
the background?

Thanks,

-- Greg
 
Your Paint method is called for every cell.
Just draw your background in there. Everything you
need is supplied in the arguments

Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics,
_
ByVal bounds As System.Drawing.Rectangle, _
ByVal source As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, _
ByVal backBrush As System.Drawing.Brush, _
ByVal foreBrush As System.Drawing.Brush, _
ByVal alignToRight As Boolean)

If noCheckbox Then
g.FillRectangle(backBrush, bounds)
Else
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush,
alignToRight)
End If

End Sub


/claes
 
Back
Top