Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have in my application a listview control which I custom draw. The problem that I'm having is that when I draw my column headers everything to the right of my last column header doesn't seem like it's being custom drawn. It looks like the default windows header. Here's the code that I use to draw the custom headers which is in the listview DrawColumHeader event handler.


VB
Dim sf As New StringFormat()
      Try

          Select Case e.Header.TextAlign
              Case HorizontalAlignment.Center
                  sf.Alignment = StringAlignment.Center
              Case HorizontalAlignment.Right
                  sf.Alignment = StringAlignment.Far
          End Select


          Using brush As Brush = New SolidBrush(GroupBoxBackcolor)
              e.Graphics.FillRectangle(brush, e.Bounds)
          End Using

          Dim bounds As Rectangle = e.Bounds

          bounds.Width -= 1
          bounds.Height -= 1

          e.Graphics.DrawRectangle(SystemPens.ControlDark, bounds)

          bounds.Width -= 1
          bounds.Height -= 1


          ' Draw the header text.
          Dim headerFont As New Font("Segoe UI", 10, FontStyle.Bold)

          Try
              e.Graphics.DrawString(e.Header.Text, headerFont, _
                  Brushes.Blue, e.Bounds, sf)
          Finally
              headerFont.Dispose()
          End Try

      Finally
          sf.Dispose()
      End Try


I'm wondering if anyone knows how I can fix this. Any help would be greatly appreciated.
Posted
Updated 22-Jan-15 7:58am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900