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
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
    Overview
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Concepts
   [Expand]Visual Elements
   [Collapse]Examples
    [Expand]Files
    [Expand]Text
    [Expand]Formatting
    [Expand]Styles
    [Expand]Lists
    [Expand]Pictures
    [Expand]Text Boxes
    [Collapse]Tables
      How to: Insert a Table
      How to: Create a Table with Fixed Column Width
      How to: Merge and Split Table Cells
      How to: Change Table Color
      How to: Create and Apply Table Style
      How to: Use Conditional Style
      How to: Delete a Table
    [Expand]Layout
    [Expand]Automation
    [Expand]Search and Replace
    [Expand]Mail Merge
    [Expand]Spell Check
    [Expand]Export-Import
    [Expand]Printing
    [Expand]Protection
    [Expand]User Interface Customization
    [Expand]Miscellaneous
    [Expand]Commands
   [Expand]Member Tables
  [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: Use Conditional Style

The Rich Edit API allows you to set formatting rules to the specific table elements (first row, first cell, odd column, etc.). This feature is called conditional styles.

To create and apply a conditional style, perform the following steps.

  1. Create new table style using the TableStyleCollection.CreateNew method.
  2. Optionally, specify the newly created style's TableStyle.Parent property to derive it from an existing style.
  3. Create separate TableConditionalStyle objects for each desired table element type that needs to be formatted. To do so, call the TableConditionalStyleProperties.CreateConditionalStyle method repeatedly and pass different ConditionalTableStyleFormattingTypes enumeration values to this method as parameters.
  4. Specify additional settings for each TableConditionalStyle object you have:
  5. Add the style created in step 1 to the table styles collection by calling the TableCellStyleCollection.Add method. Note that styles not added to a corresponding collection cannot be applied to Rich Edit elements.
  6. To apply the style to a table, set this table's Table.Style property.
  7. Specify the table elements that should be formatted using the Table.TableLook property.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E5219.

The following code creates a new table style which descends from the existing style, creates new conditional styles within that style using the TableConditionalStyleProperties.CreateConditionalStyle method and applies the style to a newly created table. Note that conditional styles are selectively applied using the Table.TableLook property.

The image below illustrates the result of code execution.

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