dotnetmonitor.com

 
Index
Previous
Next

 

If your data is read-only, the CellValueNeeded event may be the only event you will need to handle. Additional virtual-mode events let you enable specific functionality like user edits, row addition and deletion, and row-level transactions.

 

Some standard DataGridView events (such as events that occur when users add or delete rows, or when cell values are edited, parsed, validated, or formatted) are useful in virtual mode, as well. You can also handle events that let you maintain values not typically stored in a bound data source, such as cell ToolTip text, cell and row error text, cell and row shortcut menu data, and row height data.

 

The following events occur only when the VirtualMode property is set to true.

Event

Description

CellValueNeeded

Used by the control to retrieve a cell value from the data cache for display. This event occurs only for cells in unbound columns.

CellValuePushed

Used by the control to commit user input for a cell to the data cache. This event occurs only for cells in unbound columns.

Call the UpdateCellValue method when changing a cached value outside of a CellValuePushed event handler to ensure that the current value is displayed in the control and to apply any automatic sizing modes currently in effect.

NewRowNeeded

Used by the control to indicate the need for a new row in the data cache.

RowDirtyStateNeeded

Used by the control to determine whether a row has any uncommitted changes.

CancelRowEdit

Used by the control to indicate that a row should revert to its cached values.

 

The following events are useful in virtual mode, but can be used regardless of the VirtualMode property setting.

Events

Description

UserDeletingRow

UserDeletedRow

RowsRemoved

RowsAdded

Used by the control to indicate when rows are deleted or added, letting you update the data cache accordingly.

CellFormatting

CellParsing

CellValidating

CellValidated

RowValidating

RowValidated

Used by the control to format cell values for display and to parse and validate user input.

CellToolTipTextNeeded

Used by the control to retrieve cell ToolTip text when the DataSource property is set or the VirtualMode property is true.

Cell ToolTips are displayed only when the ShowCellToolTips property value is true.

CellErrorTextNeeded

RowErrorTextNeeded

Used by the control to retrieve cell or row error text when the DataSource property is set or the VirtualMode property is true.

Call the UpdateCellErrorText method or the UpdateRowErrorText method when you change the cell or row error text to ensure that the current value is displayed in the control.

Cell and row error glyphs are displayed when the ShowCellErrors and ShowRowErrors property values are true.

CellContextMenuStripNeeded

RowContextMenuStripNeeded

Used by the control to retrieve a cell or row ContextMenuStrip when the control DataSource property is set or the VirtualMode property is true.

RowHeightInfoNeeded

RowHeightInfoPushed

Used by the control to retrieve or store row height information in the data cache. Call the UpdateRowHeightInfo method when changing the cached row height information outside of a RowHeightInfoPushed event handler to ensure that the current value is used in the display of the control.

What is the DataGridView
Differences between the DataGridView and DataGrid controls
Highlight of features
Structure of DGV
Architecture Elements
Cells and Bands