我的问题是,当我连续按下向下箭头键时,列(0)(红线)上的移动会延迟
Private Sub DataGridView1_CellPainting(sender As Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
Dim gfx = e.Graphics
Dim pen As New Pen(Color.FromArgb(0, 0, 96))
If e.RowIndex > -1 And e.ColumnIndex > -1 Then
If DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Selected = True Then
e.Paint(e.CellBounds, DataGridViewPaintParts.ContentBackground)
Using cpen As New Pen(Color.Yellow, 1)
e.Graphics.DrawRectangle(cpen, e.CellBounds.X + 1, e.CellBounds.Y + 1, e.CellBounds.Width - 3, e.CellBounds.Height - 3)
End Using
e.Handled = True
ElseIf DataGridView1.SelectedCells.Count >= 0 Then
If e.RowIndex = DataGridView1.SelectedCells(0).RowIndex Then
DataGridView1.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.Red
Else
DataGridView1.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.Black
End If
End If
End If
End Sub
连续按下箭头键时,我需要第(0)列(红线)与其他列一起向下移动。