Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [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]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Collapse]Examples
    [Expand]Data Binding
    [Expand]Data Editing
    [Expand]Data Presentation
    [Expand]Export and Printing
    [Expand]Filtering
    [Expand]Formatting
    [Expand]General Use
    [Expand]Layout View
    [Expand]Master-Detail
    [Expand]Miscellaneous
    [Expand]Navigation and Selection
    [Collapse]Painting
      Examples: Painting
      How to: Custom Draw Card Captions
      How to: Custom Draw Card Field Captions
      How to: Custom Draw Card Fields
      How to: Custom Draw Cells Depending Upon Cell Values
      How to: Custom Draw Footer Cells
      How to: Custom Draw Group Rows
      How to: Custom Paint Card Field Values Depending on Field Positions
      How to: Custom Paint Group Footers
      How to: Custom Paint Row Indicators
      How to: Custom Paint Sort Glyphs Within Column Headers
      How to: Display a Custom Image Within a Group Panel
      How to: Display Custom Images in Card Captions
      How to: Display Images Within Row Preview Sections
      How to: Display Some Text When No Record is Displayed in the Grid
      How to: Dynamically Customize Cell Appearance
      How to: Dynamically Customize the Appearance of Card Captions in a Layout View
      How to: Dynamically Customize the Appearance of Card Field Captions in a Layout View
      How to: Dynamically Customize the Appearance of Card Field Values in a Layout View
      How to: Paint the sort and filter buttons when custom painting
    [Expand]Skins and Look and Feel
    [Expand]Sorting and Grouping
    [Expand]Summaries
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [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]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Custom Draw Cells Depending Upon Cell Values

The following code demonstrates how to use the CustomDrawCell event to set up the appearance of "UnitsInStock" column cells. If a cell belongs to the focused row, custom draw is not applied and the cell is drawn by default. Otherwise the background of a cell is drawn according to its value.

Also we do not perform custom painting of a cell if the "Discontinued" column cell of the same row is checked. Instead, we just change the DisplayText parameter to "Discontinued" and leave the Handled parameter set to false. This text will be drawn using the default appearance settings after performing the event handler.

If a value of the "Discontinued" column is set to false, the background of the "UnitsInStock" cell of the same row is drawn using the LightSkyBlue or "LightGreen" color according to the cell value. In ths case, the Handled parameter is set to true in order to prevent default cell painting.

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