officefileapi-devexpress-dot-spreadsheet-dot-worksheet-37edf32b.md
Obtains a collection of form controls contained in a worksheet.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
FormControlCollection FormControls { get; }
ReadOnly Property FormControls As FormControlCollection
| Type | Description |
|---|---|
| FormControlCollection |
A collection of 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>();
//...
Imports DevExpress.Spreadsheet
Imports System.Linq
Private workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")
Dim formControls = workbook.Worksheets(0).FormControls
Dim checkBoxes = formControls.Where(Function(formControl) formControl.FormControlType = FormControlType.CheckBox).Cast(Of CheckBoxFormControl)()
'...
The table below lists available form controls and API used to create each type.
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;
Imports DevExpress.Spreadsheet
Dim workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")
Dim cellRange = workbook.Worksheets(0).Range("B2:C4")
Dim buttonFormControl = formControls.AddButton(cellRange)
buttonFormControl.PlainText = "Click Here"
buttonFormControl.PrintObject = False
You can export workbooks with form controls to the following formats:
Each form control has the PrintObject property that specifies whether to print the form control. This options also affects the following operations:
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.
The Form Control API subset ships with the following limitations:
null.null for ComboBoxFormControl, ListBoxFormControl, ScrollbarFormControl, and SpinnerFormControl.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.
#region #CreateFormControls
var formControls = workbook.Worksheets[0].FormControls;
#region #CreateFormControls
var formControls = workbook.Worksheets[0].FormControls;
#region #CreateFormControls
var formControls = workbook.Worksheets[0].FormControls;
#Region "#CreateFormControls"
Dim formControls = workbook.Worksheets(CInt((0))).FormControls
' Create a button form control:
' #Region "#CreateFormControls"
Dim formControls = workbook.Worksheets(0).FormControls
See Also