officefileapi-devexpress-dot-spreadsheet-4e0b341e.md
Group box form control.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface GroupBoxFormControl :
FormControl,
Shape,
FloatingObject,
ShapeFormatBase,
TextFormControl,
ShadedFormControl
Public Interface GroupBoxFormControl
Inherits FormControl,
Shape,
FloatingObject,
ShapeFormatBase,
TextFormControl,
ShadedFormControl
The following members return GroupBoxFormControl objects:
The code sample below creates a group box control:
using DevExpress.Spreadsheet;
Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx");
var cellRange = workbook.Worksheets[0].Range["B2:F6"];
var groupBox = formControls.AddGroupBox(cellRange);
groupBox.PlainText = "Group Box";
Imports DevExpress.Spreadsheet
Dim workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")
Dim cellRange = workbook.Worksheets(0).Range("B2:F6")
Dim groupBox = formControls.AddGroupBox(cellRange)
groupBox.PlainText = "Group Box"
Note
The FormControlCollection.AddGroupBox method call adds a new item to both FormControlCollection and ShapeCollection.
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.
Use the GroupBoxFormControl class properties to change group box parameters. The code sample below obtains all group boxes and enables 3D shading:
using DevExpress.Spreadsheet;
using System.Linq;
Workbook workbook = new Workbook();
workbook.LoadDocument("Document.xlsx");
var formControls = workbook.Worksheets[0].FormControls;
var groupBoxes = formControls.Where(formControl => formControl.FormControlType == FormControlType.GroupBox).Cast<GroupBoxFormControl>();
foreach (GroupBoxFormControl groupBox in groupBoxes)
{
groupBox.Shading3D = true;
}
Imports DevExpress.Spreadsheet
Imports System.Linq
Private workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")
Dim formControls = workbook.Worksheets(0).FormControls
Dim groupBoxes = formControls.Where(Function(formControl) formControl.FormControlType = FormControlType.GroupBox).Cast(Of GroupBoxFormControl)()
For Each comboBox As GroupBoxFormControl In groupBoxes
groupBox.Shading3D = True
Next groupBox
Note
ShapeFormatBase.Fill, ShapeFormatBase.Outline property returns null for GroupBoxFormControl.
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 group boxes 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.GroupBox)
formControls.RemoveAt(i);
}
Dim workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")
Dim formControls = workbook.Worksheets(0).FormControls
For i As Integer = formControls.Count - 1 To 0 Step -1
If formControls(i).FormControlType = FormControlType.GroupBox Then
formControls.RemoveAt(i)
End If
Next i
See Also