Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Método DataGridView.InvalidateCell (DataGridViewCell)

 

Invalida a célula especificada do DataGridView, forçando-a a ser pintada novamente.

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

public void InvalidateCell(
	DataGridViewCell dataGridViewCell
)

Parâmetros

dataGridViewCell
Type: System.Windows.Forms.DataGridViewCell

O DataGridViewCell a ser invalidado.

Exception Condition
ArgumentException

dataGridViewCell não pertence a DataGridView.

ArgumentNullException

dataGridViewCell é null.

This method is useful to force a cell repaint in conditions that would not normally cause a cell to be repainted. For example, you can use this method with a custom cell type that changes its appearance as a result of external events.

For more information about painting and invalidation, see Overload:System.Windows.Forms.Control.Invalidate.

The following code example illustrates how to use this method in a customized T:System.Windows.Forms.DataGridViewCell that is painted with a custom border when the mouse pointer rests on it. In the example, the cell is invalidated when the mouse pointer enters or leaves it.

This code is part of a larger example available in How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance.

// Force the cell to repaint itself when the mouse pointer enters it.
protected override void OnMouseEnter(int rowIndex)
{
    this.DataGridView.InvalidateCell(this);
}

// Force the cell to repaint itself when the mouse pointer leaves it.
protected override void OnMouseLeave(int rowIndex)
{
    this.DataGridView.InvalidateCell(this);
}

.NET Framework
Disponível desde 2.0
Retornar ao início
Mostrar: