我有一个DataGridView
带有一个按钮的列。当我将以下代码与图像一起使用unblock3.png
时,会显示图像,但是当我将其替换为另一个图像时,check1.png
什么都不会显示。
我尝试将大小调整check1.png
为更小的尺寸,但它仍然无法正常工作。
你能帮我找出问题所在吗?
Private Sub ShiftsList_CellPainting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles ShiftsList.CellPainting
If ShiftsList.Columns(e.ColumnIndex).Name = "ConfirmShift" AndAlso e.RowIndex >= 0 Then
e.Paint(e.CellBounds, DataGridViewPaintParts.All)
e.Graphics.DrawImage(My.Resources.unblock3, CInt((e.CellBounds.Width / 2) - (My.Resources.unblock3.Width / 2)) + e.CellBounds.X, CInt((e.CellBounds.Height / 2) - (My.Resources.unblock3.Height / 2)) + e.CellBounds.Y)
e.Handled = True
End If
End Sub