Back to Devexpress

ScrollbarFormControl Interface

officefileapi-devexpress-dot-spreadsheet-e02949fd.md

latest6.5 KB
Original Source

ScrollbarFormControl Interface

Scrollbar form control.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public interface ScrollbarFormControl :
    FormControl,
    Shape,
    FloatingObject,
    ShapeFormatBase,
    RangeFormControl,
    LinkedCellFormControl,
    ShadedFormControl
vb
Public Interface ScrollbarFormControl
    Inherits FormControl,
             Shape,
             FloatingObject,
             ShapeFormatBase,
             RangeFormControl,
             LinkedCellFormControl,
             ShadedFormControl

The following members return ScrollbarFormControl objects:

Remarks

Create a Scrollbar Form Control

The code sample below creates a scrollbar form control:

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

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

var cellRange = workbook.Worksheets[0].Range["B2:B8"];
var scrollbarFormControl = formControls.AddScrollbar(cellRange);
scrollbarFormControl.Min = 2;
scrollbarFormControl.Max = 15;
scrollbarFormControl.LargeChange = 10;
scrollbarFormControl.SmallChange = 1;
vb
Dim workbook As New Workbook()
workbook.LoadDocument("Document.xlsx")

Dim formControls = workbook.Worksheets(0).FormControls

Dim cellRange = workbook.Worksheets(0).Cells("B2:B8")
Dim scrollbarFormControl = formControls.AddScrollbar(cellRange))
scrollbarFormControl.Min = 2
scrollbarFormControl.Max = 15
scrollbarFormControl.LargeChange = 10
scrollbarFormControl.SmallChange = 1

Note

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

Obtain Scrollbar 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 Scrollbar Form Controls

Use the ScrollbarFormControl class properties to change scrollbar parameters. The code sample below obtains all scrollbars 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 scrollbars = formControls.Where(formControl => formControl.FormControlType == FormControlType.Scrollbar).Cast<ScrollbarFormControl>();
foreach (ScrollbarFormControl scrollbar in scrollbars)
{
    scrollbar.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 scrollbars = formControls.Where(Function(formControl) formControl.FormControlType = FormControlType.Scrollbar).Cast(Of ScrollbarFormControl)()
For Each scrollbar As GroupBoxFormControl In scrollbars
  scrollbar.Shading3D = True
Next scrollbar

Note

ShapeFormatBase.Fill, ShapeFormatBase.Outline, and FormControl.ShapeText property returns null for ScrollbarFormControl.

Remove Scrollbar 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 scrollbars 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.Scrollbar)
        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.Scrollbar Then
    formControls.RemoveAt(i)
  End If
Next i

See Also

ScrollbarFormControl Members

DevExpress.Spreadsheet Namespace