Click here to Skip to main content
13,052,342 members (56,226 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Private Sub DataGridView2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles DataGridView2.Paint

        Dim months As String() = {"Birthday"}
        Dim j As Integer
        For j = 0 To 10
            Dim r1 As Rectangle = Me.DataGridView2.GetCellDisplayRectangle(0, -1, True)
            Dim w2 As Integer = Me.DataGridView2.GetCellDisplayRectangle(0 + 1, -1, True).Width
            r1.X += 1
            r1.Y += 1
            r1.Width = r1.Width + w2 + w2 - 2
            r1.Height = r1.Height / 1 - 1
            e.Graphics.FillRectangle(New SolidBrush(Me.DataGridView1.ColumnHeadersDefaultCellStyle.BackColor), r1)
            Dim format As StringFormat = New StringFormat()
            format.Alignment = StringAlignment.Center
            format.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(months(0), Me.DataGridView2.ColumnHeadersDefaultCellStyle.Font, New SolidBrush(Me.DataGridView2.ColumnHeadersDefaultCellStyle.ForeColor), r1, format)
            j += 2

i am using above code to paint ny header but it is creating proble whwn i drag csroll bar
Posted 29-May-13 1:03am
Updated 29-May-13 1:43am
Maciej Los255.3K
Tadit Dash 29-May-13 7:12am
Please post the code again. It is messy.
And mention what exactly is the problem and where are you stuck ?
joshrduncan2012 29-May-13 9:17am
Please re-tag your question correctly. Last time I checked what you are showing isn't C# code.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 29 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100