PC Review


Reply
Thread Tools Rate Thread

Painting DataGrid Column Headers in WinForms (C#)

 
 
John Smith
Guest
Posts: n/a
 
      8th Dec 2003

I've posted this to the WinForms forum at GotDotNet - but thought I'd also
try my luck in the WinForms NG.

Yet another DataGrid post, I'm sure... :-) But Googling the Web far and wide
has not yielded any results, and my own investigations into the
DataGrid-related classes in the Framework have been even less fruitful. So
the question is really simple (the application is less so, and I'll pose the
question for that as well, in a bit): how do I custom paint into a
DataGrid's column header area? Ideally, I'd like to do this in a derived
DataGridColumnStyle, so that I can do this for any arbitrary column and make
it part of the column's style.

The real reason I am asking is because I am trying to develop my own custom
column style for a DataGrid in which I have a column of checkboxes (much
like DataGridBoolColumn) and also a checkbox in the column header. The
functionality I'm trying to implement is to allow each row's checkbox to be
used to select/deselect the row. The checkbox in the column header, then,
would be used as a "Select All" checkbox. If there's a better place to
Show() my "Select All" checkbox (as opposed to putting it in a Paint()
method), I'm definitely all ears! (all eyes?) I think I've figured out how
to trap the event for each row to actually cause selection of the row, but I
still need to get the "Select All" to work.

I know I'm not the most familiar with the WinForms DataGrid (I only recently
figured out the "right" way to do a data-bound DataGridComboBox column,
which once I spruce up, I'll consider for posting here), but this seems to
be a simple extension that I have as yet to figure out how to approach as
far as the implementation goes.

Any thoughts/ideas/suggestions on how to do both of the above? Am I being
really naive here, or is this actually harder than it sounds (as I've
believed all along)?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get column numbers from a Winforms dataGrid sagenaut@yahoo.com Microsoft C# .NET 1 27th Jan 2007 02:11 AM
Custom painting of DataGrid column headers The_Assimilator Microsoft Dot NET Framework Forms 0 16th Feb 2006 03:45 PM
Image in DataGrid Column (WinForms) Charlie@CBFC Microsoft C# .NET 1 3rd Mar 2005 02:26 AM
DataGrid bool column winforms... Sergiu Cojocaru Microsoft C# .NET 0 29th Nov 2004 01:44 PM
DataGrid column header text painting problem Shravan Kumar Microsoft C# .NET 3 21st Oct 2003 05:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:29 AM.