1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Public Class ImageColumnHeader
Inherits DataGridViewColumnHeaderCell
Public _image As Image
Public Sub New(ByVal img As Image)
MyBase.New()
Me._image = img
End Sub
Protected Overloads Overrides Sub Paint(ByVal graphics As Graphics, ByVal clipBounds As Rectangle, ByVal cellBounds As Rectangle, ByVal rowIndex As Integer, ByVal dataGridViewElementState As DataGridViewElementStates, ByVal value As Object, _
ByVal formattedValue As Object, ByVal errorText As String, ByVal cellStyle As DataGridViewCellStyle, ByVal advancedBorderStyle As DataGridViewAdvancedBorderStyle, ByVal paintParts As DataGridViewPaintParts)
MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value, _
formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts)
graphics.DrawImage(_image, cellBounds.X + 2, cellBounds.Y + 2)
End Sub
Protected Overloads Overrides Function GetValue(ByVal rowIndex As Integer) As Object
Return Nothing
End Function
Public Property Icon() As Image
Get
Return _image
End Get
Set(ByVal value As Image)
_image = value
End Set
End Property
End Class |
Partager