Skip to main content
All docs
V23.2
Row

Worksheet.FormControls Property

Obtains a collection of form controls contained in a worksheet.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v23.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

FormControlCollection FormControls { get; }

Property Value

Type Description
FormControlCollection

A collection of form controls.

Remarks

Access Form Controls

The Worksheet.FormControls property obtains all form controls in a worksheet. You can use one of the following ways to obtain a specific form control:

The FormControl.Id and FormControl.Name properties return the form control’s identifier and name.

The code snippet below shows how to get all check box form controls:

using DevExpress.Spreadsheet;
using System.Linq;

Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx");

var formControls = workbook.Worksheets[0].FormControls;

var checkBoxes = formControls.Where(formControl => formControl.FormControlType == FormControlType.CheckBox).Cast<CheckBoxFormControl>();
//...

Create Form Controls

The table below lists available form controls and API used to create each type.

Form Control Class Method
Button ButtonFormControl FormControlCollection.AddButton
Check Box CheckBoxFormControl FormControlCollection.AddCheckBox
Combo box ComboBoxFormControl FormControlCollection.AddComboBox
Group box GroupBoxFormControl FormControlCollection.AddGroupBox
List box ListBoxFormControl FormControlCollection.AddListBox
Radio Button RadioButtonFormControl FormControlCollection.AddRadioButton
Scrollbar ScrollbarFormControl FormControlCollection.AddScrollbar
Spin Button SpinnerFormControl FormControlCollection.AddSpinner

Note

The FormControlCollection.Add... method call adds a new item to both FormControlCollection and ShapeCollection.

The code sample below creates a button form control:

using DevExpress.Spreadsheet;

Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx");
var cellRange = workbook.Worksheets[0].Range["B2:C4"];
var buttonFormControl = formControls.AddButton(cellRange);
buttonFormControl.PlainText = "Click Here";
buttonFormControl.PrintObject = false;

Available Export Formats

You can export workbooks with form controls to the following formats:

  • XLSX
  • XLSM
  • XLTX
  • XLTM
  • PDF

Disable Printing

Each form control has the PrintObject property that specifies whether to print the form control. This options also affects the following operations:

  • Form control export to PDF format
  • Export a cell range that contains a form control to an image
  • Export a worksheet with form controls to an image

Remove Form Controls

Call the FormControlCollection.Remove or FormControlCollection.RemoveAt method to remove a form control.

The FormControlCollection.Clear() method call removes all form controls from a worksheet.

Limitations

The Form Control API subset ships with the following limitations:

The following code snippets (auto-collected from DevExpress Examples) contain references to the FormControls property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also