Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TcxScrollBar.OnScroll Event

In This Article

Enables you to respond to thumb scrolling.

#Declaration

Delphi
property OnScroll: TScrollEvent read; write;

#Remarks

Handle this event to respond to end-user thumb scrolling and adjust the resulting scrollbar value accordingly.

The Sender parameter provides access to the scrollbar that fired the event.

The ScrollCode parameter identifies the end-user action that initiated thumb scrolling. Once thumb scrolling is finished, this parameter returns scEndScroll.

The ScrollPos parameter contains a new Position property value to be assigned as the result of thumb scrolling. You can adjust this value as required.

The following code example demonstrates how to handle the OnScroll event to cancel any end-user thumb scrolling based on a specific condition.

Delphi
var
  AStoredPos: Integer = -1;
// ...
procedure <Form>.<cxScrollBar>Scroll(Sender: TObject; ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
  if (ScrollCode <> scEndScroll) and (AStoredPos = -1) then
    AStoredPos := cxScrollBar1.Position
  else if (<Your condition here>) and (ScrollCode = scEndScroll) then
  begin
    ScrollPos := AStoredPos;
    AStoredPos := -1;
  end;
end;
See Also