Log In
[Expand]General Information
[Collapse]WinForms Controls
 [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]Getting Started
   [Expand]Binding to Data
   [Collapse]Grid View
    [Expand]Columns and Card Fields
    [Expand]Rows and Cards
    [Expand]Row, Column and Cell Access API
    [Expand]Split Presentation
    [Expand]Cell Merging
    [Collapse]Row Preview Sections
      Preview Overview
      Tutorial: Customize Row Preview Sections
      Tutorial: Row Preview Sections
      Custom Preview Text
   [Expand]View Technology
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [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]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Custom Preview Text

Expanded Online Video

Learn how to customize the content and size of row preview sections using dedicated events.

Expanded Custom Preview Text

Grid Control provides a preview feature and this allows each row to display a preview section. The preview section is a suitable place to display memo fields or custom data for each record. The Preview Overview document provides basic information about preview sections.

This topic describes how to customize a preview section at runtime in detail.

Initially, the text displayed within a preview is extracted from the database field, but you can also customize the text by handling the GridView.CalcPreviewText event. Use the event's CalcPreviewTextEventArgs.PreviewText parameter to specify the preview text. The following code displays the name and address in the preview section. The ColumnView.GetRowCellValue method is used to obtain current cell data and insert it into the preview.

Expanded Custom Painting Preview Sections

It is also possible to custom paint preview sections by handling the GridView.CustomDrawRowPreview event. When using this event you have additional capabilities for customizing preview sections (draw the graphics and text in any position). However, note that the results of custom painting cannot be printed out or exported.

Expanded Example

The example shows how you can customize the View's preview section via the GridView.CustomDrawRowPreview event. In the example, we draw an image from the "Photo" column to the left of the text itself. The static FromByteArray function allows you to convert an array of bytes returned by a cell to an System.Drawing.Image object.

Expanded See Also

How would you rate this topic?​​​​​​​