LabelFormControl Interface
Label form control.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
#Declaration
public interface LabelFormControl :
FormControl,
Shape,
FloatingObject,
ShapeFormatBase,
TextFormControl
#Related API Members
The following members return LabelFormControl objects:
#Remarks
#Create a Label Form Control
The code sample below creates a combo box control:
using DevExpress.Spreadsheet;
Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx");
var cellRange = spreadsheetControl.Document.Worksheets[0].Range["B2:C2"];
var labelFormControl = formControls.AddLabel(cellRange);
labelFormControl.PlainText = "Label";
Note
The Form
#Obtain Label 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:
- Access the item in the collection by its index
- Call the FormControlCollection.GetFormControlsByName method
- Call the FormControlCollection.GetFormControlById method
The FormControl.Id and FormControl.Name properties return the form control’s identifier and name.
#Modify Label Form Controls
Use the LabelFormControl
class properties to change label form control parameters. The code sample below obtains all labels and locks them from editing:
using DevExpress.Spreadsheet;
using System.Linq;
Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx");
var formControls = spreadsheetControl.Document.Worksheets[0].FormControls;
var labels = formControls.Where(formControl => formControl.FormControlType == FormControlType.Label).Cast<LabelFormControl>();
foreach (LabelFormControl label in labels)
{
label.LockText = true;
}
Note
Shapenull
for Label
.
#Remove Label Form Controls
Call the FormControlCollection.Remove or FormControlCollection.RemoveAt method to remove a form control. The FormControlCollection.Clear() method removes all form controls from a worksheet.
The code sample below removes all labels from a worksheet:
Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx");
var formControls = workbook.Worksheets[0].FormControls;
for (int i = formControls.Count - 1; i >= 0; i--) {
if (formControls[i].FormControlType == FormControlType.Label)
formControls.RemoveAt(i);
}