Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Hiding DataGridBoolColumn checkboxes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg Allen - 08 Dec 2004 12:05 GMT
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
Claes Bergefall - 09 Dec 2004 08:57 GMT
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

> Is there a way to hide a checkbox on a particular row of a column that
> is a DataGridBoolColumn?
[quoted text clipped - 8 lines]
>
> -- Greg
Greg Allen - 09 Dec 2004 13:03 GMT
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

> Inherit DataGridBoolColumn and override its Paint method
> In the cases where you want the checkbox you can simply
[quoted text clipped - 17 lines]
>>
>> -- Greg
Claes Bergefall - 10 Dec 2004 09:04 GMT
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

> 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
[quoted text clipped - 3 lines]
>
> -- Greg

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.