Private Sub Form1_Paint(...) Handles Me.Paint
' Find cell (1, 2).
Dim rect As Rectangle = _
DataGridView1.GetCellDisplayRectangle(1, 1, False)
Dim x1 As Integer = DataGridView1.Left
Dim y1 As Integer = DataGridView1.Top
Dim the_pen As Pen
If DataGridView1.Rows(1).Cells(1).Displayed Then
the_pen = Pens.Blue
Else
the_pen = Pens.Red
End If
e.Graphics.DrawLine(the_pen, 0, y1 + rect.Top, _
Me.ClientSize.Width, y1 + rect.Top)
e.Graphics.DrawLine(the_pen, 0, y1 + rect.Bottom, _
Me.ClientSize.Width, y1 + rect.Bottom)
e.Graphics.DrawLine(the_pen, x1 + rect.Left, 0, x1 + _
rect.Left, Me.ClientSize.Height)
e.Graphics.DrawLine(the_pen, x1 + rect.Right, 0, x1 + _
rect.Right, Me.ClientSize.Height)
End Sub
|