Skip to content

ScrollBar Class

Represents a scrollbar control.

C#
[DataContract]
public class ScrollBar : ControlBase

Inheritance objectControlBase

Creates a new Slider control

C#
public ScrollBar(Orientation orientation, int size)

orientation Orientation
Sets the control to either horizontal or vertical.

size int
The height or width of the control, based on the orientation, with a thickness of 1.

ArgumentOutOfRangeException
Size of the control must be 2 or more

Creates a new Slider control with the specified width and height.

C#
public ScrollBar(Orientation orientation, int width, int height)

orientation Orientation
Sets the control to either horizontal or vertical.

width int
The width the control.

height int
The height of the control.

ArgumentOutOfRangeException
With a horizontal Slider, width must be 2 or more. With a vertical Slider, height must be 2 or more.

Indicates if the slider is horizontal or vertical.

C#
[DataMember]
public Orientation Orientation { get; }

When true, indicates that the mouse is gripping the slider to scroll.

C#
public bool IsGripped { get; }

Gets or sets the maximum value for the scrollbar.

C#
[DataMember]
public int MaximumValue { get; set; }

Gets or sets the amount of values to add or subtract to the Value when the up or down arrows are used.

C#
[DataMember]
public int ArrowStep { get; set; }

Gets or sets the amount of values to add or subtract to the Value when the up or down arrows are used.

C#
[DataMember]
public int MouseWheelStep { get; set; }

Gets or sets the value of the slider between the minimum and maximum values.

C#
[DataMember]
public int Value { get; set; }

When true, the arrow buttons simply move the grip instead of using the ArrowStep value to adjust the value.

C#
[DataMember]
public bool ArrowsMoveGrip { get; set; }

When true, the mouse wheelsimply moves the grip instead of using the MouseWheelStep value to adjust the value.

C#
[DataMember]
public bool MouseWheelMovesGrip { get; set; }

The style applied to drawing the control.

C#
[DataMember]
public ScrollBar.ThemeStyle Style { get; set; }

Invokes the ValueChanged event.

C#
protected void OnValueChanged()

Sets the bar and grip sizes of the control.

C#
protected void CalculateGripSize()

Moves the grip position based on the Value property.

C#
protected void SetGripToValue()

Resizes the control and recalculates the grip size.

C#
protected override void OnResized()

Sets the value of the control without using the Value property. Optionally calls SetGripToValue().

C#
protected void SetValue(int value, bool setGrip = true)

value int
The value to set.

setGrip bool
Moves the grip when true.

Increases the value by the specified amount.

C#
public void IncreaseValue(int value)

value int
The value to add to Value.

Decreases the value by the specified amount.

C#
public void DecreaseValue(int value)

value int
The value to subract from Value.

Increases the grip position by one and sets the value.

C#
public void IncreaseGripByOne()

Decreases the grip position by one and sets the value.

C#
public void DecreaseGripByOne()

Processes the mouse wheel values regardless of if the mouse is over the scrollbar or not.

C#
public bool ProcessMouseWheel(MouseScreenObjectState state)

state MouseScreenObjectState
The mouse state.

bool
True if the mouse wheel was processed.

Checks if the mouse is the control and calls the appropriate mouse methods.

C#
public override bool ProcessMouse(MouseScreenObjectState state)

state MouseScreenObjectState
Mouse information.

bool
True when the control is enabled, set to use the mouse and the mouse is over it, otherwise false.

Redraws the control if applicable.

C#
public override void UpdateAndRedraw(TimeSpan time)

time TimeSpan
The duration of thecurrent frame.

Raised when the Value property changes.

C#
public event EventHandler? ValueChanged

EventHandler