Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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
 
        Next
 
i am using above code to paint ny header but it is creating proble whwn i drag csroll bar
Posted 29-May-13 2:03am
rahuls11.1K
Edited 29-May-13 2:43am
(no name)151.8K
v2
Comments
Tadit Dash at 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 at 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
0 Marcin Kozub 310
1 OriginalGriff 248
2 Sergey Alexandrovich Kryukov 215
3 Richard MacCutchan 202
4 Praneet Nadkar 197
0 OriginalGriff 8,048
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 29 May 2013
Copyright © CodeProject, 1999-2014
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