[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]Property 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
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
   [Expand]Fields
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Printing
    Spell Checking
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Services
    Events
    Commands
    Keyboard Shortcuts
    HTML Tag Support
   [Collapse]Examples
    [Expand]Files
    [Expand]Text
    [Expand]Formatting
    [Expand]Styles
    [Expand]Lists
    [Expand]Pictures
    [Expand]Text Boxes
    [Expand]Tables
    [Collapse]Document Elements
      How to: Insert Bookmark or Hyperlink
      How to: Create, Edit and Delete Comments
      How to: Specify Document Properties
      How to: Create and Modify Header
      How to: Create a Checkbox
    [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]Commands
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [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]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Create a Checkbox

Follow the steps below to create a CheckBox object in code:

  1. Access the document's form fields collection using the SubDocument.FormFields property and call the FormFieldCollection.InsertCheckBox method to create a CheckBox object at the specified document position. In the example below, the checkbox is created at the caret's position.

    Note

    Checkboxes cannot be inserted to the document header, footer, comments or floating objects (text boxes or shapes). Otherwise, an FormFieldIncorrectSubDocumentException occurs.

  2. Define the name of the bookmark associated with the current CheckBox object using the FormField.Name property.

  3. Specify the checkbox's state using the CheckBox.State property.

  4. Use the CheckBox.SizeMode property to define the checkbox's size. Selecting the CheckBoxSizeMode.Auto mode resizes the checkbox according to the current font size value (returned by the CharacterPropertiesBase.FontSize property). Set the SizeMode property to CheckBoxSizeMode.Exact and specify the CheckBox.Size value to specify the checkbox's size.

  5. You can add instructional text to the checkbox. This text can be displayed in the status bar or when focusing the checkbox and pressing F1. Specify the help text type and the text using the following members:

    When setting the HelpTextType or StatusTextType property to FormFieldTextType.Auto, make sure that the provided HelpText or StatusText value is equal to one of the AutoText gallery's entries (stored as the Normal.dotm file in the system's Templates folder). Otherwise, the help text is not displayed.

    Note

    Currently, the RichEditControl cannot display any instructional text.

  6. Set the FormField.CalculateOnExit property to true to update the checkbox's value on exit.

Show Me

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

The following code sample shows how to create a checkbox on a caret's position:

Expanded See Also

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