officefileapi-devexpress-dot-spreadsheet-e02949fd.md
Scrollbar form control.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface ScrollbarFormControl :
FormControl,
Shape,
FloatingObject,
ShapeFormatBase,
RangeFormControl,
LinkedCellFormControl,
ShadedFormControl
Public Interface ScrollbarFormControl
Inherits FormControl,
Shape,
FloatingObject,
ShapeFormatBase,
RangeFormControl,
LinkedCellFormControl,
ShadedFormControl
The following members return ScrollbarFormControl objects:
The code sample below creates a scrollbar form control:
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;
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.
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 ScrollbarFormControl class properties to change scrollbar parameters. The code sample below obtains all scrollbars 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 scrollbars = formControls.Where(formControl => formControl.FormControlType == FormControlType.Scrollbar).Cast<ScrollbarFormControl>();
foreach (ScrollbarFormControl scrollbar in scrollbars)
{
scrollbar.Shading3D = true;
}
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.
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:
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);
}
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