[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Get Started With Data Grid and Views
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
   [Expand]Filter and Search
   [Expand]Focus and Selection Handling
    Format Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Collapse]Appearance and Conditional Formatting
    [Collapse]Custom Painting
      Custom Painting Basics
      Custom Painting Scenarios
      Elements that Can Be Custom Painted
      Manually Invalidating Controls
    [Expand]Alpha Blending and Background Images
    Split Presentation
    Row Preview Sections
   [Expand]Batch Modifications
    Hit Information
    Popup Menus
   [Expand]Save and Restore Layout
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Manually Invalidating Controls

The grid control automatically repaints its elements when their appearance or display information changes. For instance, the grid automatically repaints the footer panel after summary values change. In some cases, you may need to manually invoke an element's rendering.

For example, you may want to display the number of selected rows in the Group Panel. To do this, handle the GridView.CustomDrawFooter event. The group panel is not repainted automatically after the number of selected rows changes. Thus, you should manually invoke the group panel rendering (the GridView.InvalidateGroupPanel method) in response to row selection changes (the ColumnView.SelectionChanged event).

Consider another example, in which you need to customize cells' appearance according to an external control's state. You can specify data cells' appearance using the GridView.RowCellStyle event, and force data cells to be repainted each time the external control's state changes by calling the BaseView.LayoutChanged method.

To manually invalidate a grid element, call a dedicated invalidation method the Data Grid control provides. An invalidation method adds the region the element occupies to the control's update region. Update regions are repainted asynchronously (during the next paint operation). To force asynchronous painting, call the GridControl.Update method after calling an invalidation method.

To invalidate an entire view, use the BaseView.Invalidate method. The BaseView.InvalidateRect method allows you to repaint a specific View region. In most cases, however, you need to update particular grid elements (not the entire view). For this purpose, call one of the methods listed in the table below.

Invalidation method Grid element being invalidated
BaseView.InvalidateHitObject The View element at the point the hit information object specifies.
CardView.InvalidateCard A Card.
CardView.InvalidateCardField A Card Field.
GridView.InvalidateColumnHeader A particular Column Header or the entire Column Header Panel.
GridView.InvalidateFilterPanel The Filter Panel.
GridView.InvalidateFooter The View Footer.
GridView.InvalidateGroupPanel The Group Panel.
GridView.InvalidateRow A row.
GridView.InvalidateRowCell A Row Cell.
GridView.InvalidateRowIndicator A row indicator cell.
GridView.InvalidateRows All rows within the View.
GridView.UpdateColumnsCustomization The Customization Form.
BandedGridView.InvalidateBandHeader A Band Header or the entire band header panel.

Expanded Example

The following example demonstrates how to display the number of currently selected rows in the Group Panel by handling the GridView.CustomDrawGroupPanel event. The group panel is not automatically repainted after the row selection changes. To resolve the issue, handle the ColumnView.SelectionChanged event and call the GridView.InvalidateGroupPanel method to invalidate the group panel and raise the GridView.CustomDrawGroupPanel event.

Expanded See Also

Is this topic helpful?​​​​​​​