Back to Devexpress

GroupBoxFormControl Interface

officefileapi-devexpress-dot-spreadsheet-4e0b341e.md

latest6.0 KB
Original Source

GroupBoxFormControl Interface

Group box form control.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public interface GroupBoxFormControl :
    FormControl,
    Shape,
    FloatingObject,
    ShapeFormatBase,
    TextFormControl,
    ShadedFormControl
vb
Public Interface GroupBoxFormControl
    Inherits FormControl,
             Shape,
             FloatingObject,
             ShapeFormatBase,
             TextFormControl,
             ShadedFormControl

The following members return GroupBoxFormControl objects:

Remarks

Create a Group Box Form Control

The code sample below creates a group box control:

csharp
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";
vb
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.

Obtain Group Box 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.

Modify Group Box Form Controls

Use the GroupBoxFormControl class properties to change group box parameters. The code sample below obtains all group boxes and enables 3D shading:

csharp
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;

}
vb
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.

Remove Group Box 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 group boxes from a worksheet:

csharp
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);
}
vb
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

GroupBoxFormControl Members

DevExpress.Spreadsheet Namespace