Back to Devexpress

RadioButtonFormControl Interface

officefileapi-devexpress-dot-spreadsheet-280c936d.md

latest6.1 KB
Original Source

RadioButtonFormControl Interface

Radio button form control.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

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

The following members return RadioButtonFormControl objects:

Remarks

Create a Button Form Control

The code sample below creates a button form control:

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

var cellRange = workbook.Worksheets[0].Range["B2:C4"];
var radioButtonFormControl = formControls.AddRadioButton(cellRange);
radioButtonFormControl.PlainText = "Click Here";
radioButtonFormControl.PrintObject = false;
vb
Dim workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")

Dim cellRange = workbook.Worksheets(0).Range("B2:C4")
Dim radioButtonFormControl = formControls.AddRadioButton(cellRange)
radioButtonFormControl.PlainText = "Click Here"
radioButtonFormControl.PrintObject = False

Note

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

Obtain Button 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 Id and Name properties return the form control’s identifier and name.

Modify Button Form Controls

Use the RadioButtonFormControl class properties to change radio button parameters.

Note

The ShapeFormatBase.Fill and ShapeFormatBase.Outline properties return null for the ButtonFormControl.

The code sample below retrieves all radio button form controls from a worksheet and disables printing for all buttons:

csharp
using DevExpress.Spreadsheet;
using System.Linq;

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

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

var radioButtons = formControls.Where(formControl => formControl.FormControlType == FormControlType.RadioButton).Cast<RadioButtonFormControl>();
foreach (ButtonFormControl radioButton in radioButtons) {
    radioButton.PrintObject = false;
}
vb
Imports DevExpress.Spreadsheet
Imports System.Linq

Private workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")

Dim formControls = workbook.Worksheets(0).FormControls

Dim radioButtons = formControls.Where(Function(formControl) formControl.FormControlType = FormControlType.RadioButton).Cast(Of RadioButtonFormControl)()
For Each radioButton As ButtonFormControl In radioButtons
  radioButton.PrintObject = False
Next radioButton

Remove Button Form Controls

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

The code sample below removes all radio buttons 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.RadioButton)
        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.RadioButton Then
    formControls.RemoveAt(i)
  End If
Next i

See Also

RadioButtonFormControl Members

DevExpress.Spreadsheet Namespace