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 / June 2007

Tip: Looking for answers? Try searching our database.

Unable to change the column header text in DataGridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oldman - 25 Jun 2007 23:04 GMT
I am trying to change the column header text to red and I have this code:

dCol.HeaderCell.Style.ForeColor = Color.Red;

This change does indeed stick and I can see it in the debugger.  However,
the column name text is still showing up as black.  I have seen this same
problem asked around but with no answer.  Does anybody know what is going on?

Thanks.
Manish Bafna - 26 Jun 2007 06:34 GMT
Hi,
Try following code:
DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy
DataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
DataGridView1.ColumnHeadersDefaultCellStyle.Font = New
Font(songsDataGridView.Font, FontStyle.Bold)
--
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> I am trying to change the column header text to red and I have this code:
>
[quoted text clipped - 5 lines]
>
> Thanks.
Manish Bafna - 26 Jun 2007 06:41 GMT
Hi,
In order to set forecolor/backcolor of particular column you can something
like this:
DataGridView1..Columns[4].DefaultCellStyle.BackColor = Color.Navy
DataGridView1..Columns[4].DefaultCellStyle.ForeColor = Color.White
dataGridView1.Columns[4].DefaultCellStyle.Font = new
Font(DataGridView.DefaultFont, FontStyle.Italic);
Signature

Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> I am trying to change the column header text to red and I have this code:
>
[quoted text clipped - 5 lines]
>
> Thanks.
Oldman - 26 Jun 2007 11:21 GMT
Wouldn't that change the colors of all the cells in that column?
I just want the header cell text color to change.

> Hi,
> In order to set forecolor/backcolor of particular column you can something
[quoted text clipped - 13 lines]
> >
> > Thanks.
Manish Bafna - 26 Jun 2007 13:19 GMT
Hi,
Try this code:
dataGridView.Rows(0).Cells(2).DefaultCellStyle.BackColor = Color.Navy
//for setting backcolor of second column
Signature

Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> Wouldn't that change the colors of all the cells in that column?
> I just want the header cell text color to change.
[quoted text clipped - 16 lines]
> > >
> > > Thanks.
Oldman - 26 Jun 2007 14:01 GMT
I found the problem.  I needed to set EnableHeadersVisualStyles = false.

> Hi,
> Try this code:
[quoted text clipped - 21 lines]
> > > >
> > > > Thanks.

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.