Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Custom Column Color changes text color in ListView

Posted on 2010-09-21
5
Medium Priority
?
431 Views
Last Modified: 2012-05-10
Hi,

I am trying to have a custom header color in a listview. I have found a piece of code that does this, however it overrides the ForeColor color.

This is the code:
 Private Sub listView1_DrawColumnHeader(ByVal sender As Object, ByVal e As DrawListViewColumnHeaderEventArgs) Handles ListView1.DrawColumnHeader

        Dim strFormat As New StringFormat()
        e.Header.TextAlign = HorizontalAlignment.Center
        e.DrawBackground()
        e.Graphics.FillRectangle(Brushes.Black, e.Bounds)
        
        Dim headerFont As New Font("Arial", 8, FontStyle.Bold)
        e.Graphics.DrawString(e.Header.Text, headerFont, Brushes.White, e.Bounds, strFormat)
    End Sub

Open in new window


Is there anywhere I can set the forecolor inside that function for the entire listview? Or is this code pretty crap?

Thanks
0
Comment
Question by:DanielBlackmore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 2000 total points
ID: 33724735
0
 

Author Comment

by:DanielBlackmore
ID: 33725067
I have looked at this already, IT doesnt seem to work properly. I have tried modifying it but its just not working. I am trying to have a black background on the form, black table and black headers with white text.

That code wont let me change the column text color, and it also puts in place a white bar seperating the columns
0
 
LVL 33

Expert Comment

by:jppinto
ID: 33726185
Take a look at this example from Code Project:

http://www.codeproject.com/KB/list/customheader.aspx

jppinto
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33732537
"That code wont let me change the column text color, and it also puts in place a white bar seperating the columns"
You have to delete your previous Listview and drag the new one from toolbox...
after you drag the custom control into your from try check the listview properties OwnerDraw=True
Also Form The Class You might change even the fore color.....
0
 

Author Closing Comment

by:DanielBlackmore
ID: 33769984
Thanks alot!
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question