Dim MyDataTable As New DataTable()
With MyDataTable
.Columns.Add("Col1")
.Columns.Add("Col2")
For i As Integer = 0 To 4
.Rows.Add(i, Rnd())
Next
End With
With DataGridView1
.DataSource = MyDataTable
.ReadOnly = True
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
.RowHeadersVisible = False
End With
End Sub
Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) _
Handles DataGridView1.CellPainting
With DataGridView1
Dim Rectangle1 As Rectangle = .GetCellDisplayRectangle(0, 0, True)
Dim Rectangle2 As Rectangle = .GetCellDisplayRectangle(0, 1, True)
Dim Rectangle3 As Rectangle = .GetCellDisplayRectangle(0, 2, True)
Dim Rectangle4 As Rectangle = .GetCellDisplayRectangle(0, 3, True)
Dim Rectangle5 As Rectangle = .GetCellDisplayRectangle(0, 4, True)
Rectangle1.X += 1
Rectangle1.Width -= 2
Rectangle1.Height = Rectangle1.Height + Rectangle2.Height + Rectangle3.Height + Rectangle4.Height + Rectangle5.Height - 1
e.Graphics.FillRectangle(Brushes.White, Rectangle1)
e.Graphics.DrawString("Merge", .Font, Brushes.Red, Rectangle3)
end with
end sub
沒有留言:
張貼留言