DataGridViewRowPostPaintEventArgs::DrawFocus Method (Rectangle, Boolean)

 

Draws the focus rectangle around the specified bounds.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
void DrawFocus(
	Rectangle bounds,
	bool cellsPaintSelectionBackground
)

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.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: