DataGridViewRowPostPaintEventArgs::DrawFocus Method (Rectangle, Boolean)
Draws the focus rectangle around the specified bounds.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- bounds
-
Type:
System.Drawing::Rectangle
A Rectangle that specifies the focus area.
- cellsPaintSelectionBackground
-
Type:
System::Boolean
true to use the SelectionBackColor property of the DataGridViewRow::InheritedStyle property to determine the color of the focus rectangle; false to use the BackColor property of the DataGridViewRow::InheritedStyle property.
| Exception | Condition |
|---|---|
| InvalidOperationException | RowIndex is less than zero or greater than the number of rows in the DataGridView control minus one. |
Use the DrawFocus method when you draw the DataGridViewRow and its cells' contents yourself.
The following code example demonstrates how to use the DrawFocus method to draw a focus around the visible cells of the row. This example is part of a larger example available in How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control.
Available since 2.0