Back to Devexpress

FormControlCollection.AddButton(CellRange) Method

officefileapi-devexpress-dot-spreadsheet-dot-formcontrolcollection-dot-addbutton-x28-devexpress-dot-spreadsheet-dot-cellrange-x29.md

latest5.1 KB
Original Source

FormControlCollection.AddButton(CellRange) Method

Creates a button form control at the specified cell range.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
ButtonFormControl AddButton(
    CellRange targetRange
)
vb
Function AddButton(
    targetRange As CellRange
) As ButtonFormControl

Parameters

NameTypeDescription
targetRangeCellRange

A cell range where the form control should be located.

|

Returns

TypeDescription
ButtonFormControl

A button form control.

|

Remarks

Example

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 buttonFormControl = formControls.AddButton(cellRange);
buttonFormControl.PlainText = "Click Here";
buttonFormControl.PrintObject = false;
vb
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

The following code snippets (auto-collected from DevExpress Examples) contain references to the AddButton(CellRange) method.

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.

winforms-spreadsheetcontrol-api-part-3/CS/SpreadsheetControl_API_Part03/CodeExamples/FormControlActions.cs#L19

csharp
var buttonCellRange = workbook.Worksheets[0].Range["B2:C2"];
var buttonFormControl = formControls.AddButton(buttonCellRange);
buttonFormControl.PlainText = "Click Here";

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/FormControlActions.cs#L22

csharp
var buttonCellRange = workbook.Worksheets[0].Range["B2:C2"];
var buttonFormControl = formControls.AddButton(buttonCellRange);
buttonFormControl.PlainText = "Click Here";

spreadsheet-document-api-examples-part2/CS/SpreadsheetDocServerAPIPart2/CodeExamples/FormControlActions.cs#L22

csharp
var buttonCellRange = workbook.Worksheets[0].Range["B2:C2"];
var buttonFormControl = formControls.AddButton(buttonCellRange);
buttonFormControl.PlainText = "Click Here";

winforms-spreadsheetcontrol-api-part-3/VB/SpreadsheetControl_API_Part03/CodeExamples/FormControlActions.vb#L17

vb
Dim buttonCellRange = workbook.Worksheets(CInt((0))).Range("B2:C2")
Dim buttonFormControl = formControls.AddButton(buttonCellRange)
buttonFormControl.PlainText = "Click Here"

spreadsheet-document-api-examples-part2/VB/SpreadsheetDocServerAPIPart2/CodeExamples/FormControlActions.vb#L19

vb
Dim buttonCellRange = workbook.Worksheets(0).Range("B2:C2")
Dim buttonFormControl = formControls.AddButton(buttonCellRange)
buttonFormControl.PlainText = "Click Here"

See Also

FormControlCollection Interface

FormControlCollection Members

DevExpress.Spreadsheet Namespace