자료실

부자는 돈을 써서 시간을 아끼지만 가난한 사람은 시간을 써서 돈을 아낀다

vb.net

IT HUB를 찾아주셔서 감사합니다.

Controls [vb.net] DataGridView 헤더 병합

페이지 정보

profile_image
작성자 하나를하더라도최선을
댓글 0건 조회 6,654회 작성일 21-05-02 11:42

본문

        dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        dgv.ColumnHeadersHeight *= 2
        AddHandler dgv.Paint, Sub(ByVal sd As ObjectByVal ee As PaintEventArgs)
                                  Dim monthes As String() = {"Total""Correct""Wrong""Score"}
                                  Dim j As Integer = 3
                                  Dim pDGV As DataGridView = CType(sd, DataGridView)
 
                                  Try
                                      While j < 18
                                          Dim r1 As Rectangle = pDGV.GetCellDisplayRectangle(j, -1True)
                                          Dim w2 As Integer = pDGV.GetCellDisplayRectangle(j + 1-1True).Width + pDGV.GetCellDisplayRectangle(j + 2-1True).Width + pDGV.GetCellDisplayRectangle(j + 3-1True).Width
                                          r1.X += 1
                                          r1.Y += 1
                                          r1.Width = r1.Width + w2 - 2
                                          r1.Height = r1.Height / 2 - 2
                                          '// e.Graphics.FillRectangle(New SolidBrush(DGV.ColumnHeadersDefaultCellStyle.BackColor), r1)
                                          If monthes((j - 3/ 4= "Score" Then
                                              ee.Graphics.FillRectangle(New SolidBrush(Color.Black), r1)
                                          Else
                                              ee.Graphics.FillRectangle(New SolidBrush(Color.DarkGray), r1)
                                          End If
                                          ee.Graphics.DrawLine(New Pen(New SolidBrush(Color.LightCyan)), r1.Left, r1.Bottom - 1, r1.Right, r1.Bottom - 1)
                                          Dim format As New StringFormat()
                                          format.Alignment = StringAlignment.Center
                                          format.LineAlignment = StringAlignment.Center
                                          ee.Graphics.DrawString(monthes((j - 3/ 4), pDGV.ColumnHeadersDefaultCellStyle.Font, New SolidBrush(Color.White), r1, format)
                                          j += 4
                                      End While
                                  Catch ex As Exception
                                  End Try
                              End Sub

댓글목록

등록된 댓글이 없습니다.