Permalink
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (43 sloc) 3.04 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
How to: Perform a Custom Action Based on Changes in a Cell of a Windows Forms DataGridView Control
03/30/2017
.net-framework
dotnet-winforms
article
jsharp
cells, detecting changes
DataGridView control [Windows Forms], detecting changes in cells
data grids, detecting changes in cells
7fa44d01-97f4-4ccb-a149-bc72628d2c36
13
dotnet-bot
dotnetcontent
wpickett

How to: Perform a Custom Action Based on Changes in a Cell of a Windows Forms DataGridView Control

The xref:System.Windows.Forms.DataGridView control has a number of events you can use to detect changes in the state of xref:System.Windows.Forms.DataGridView cells. Two of the most commonly used are the xref:System.Windows.Forms.DataGridView.CellValueChanged and xref:System.Windows.Forms.DataGridView.CellStateChanged events.

To detect changes in the values of DataGridView cells

To detect changes in the states of DataGridView cells

Compiling the Code

This example requires:

  • A xref:System.Windows.Forms.DataGridView control named dataGridView1. For C#, the event handlers must be connected to the corresponding events.

  • References to the xref:System?displayProperty=nameWithType and xref:System.Windows.Forms?displayProperty=nameWithType assemblies.

See Also

xref:System.Windows.Forms.DataGridView
xref:System.Windows.Forms.DataGridView.CellValueChanged?displayProperty=nameWithType
xref:System.Windows.Forms.DataGridView.CellStateChanged?displayProperty=nameWithType
Programming with Cells, Rows, and Columns in the Windows Forms DataGridView Control
Walkthrough: Validating Data in the Windows Forms DataGridView Control