Occurs when the scroll position has been changed.
![]() | Type | Description | ||
| Horizontal as Boolean | A boolean expression that indicates whether the horizontal scroll bar has changed. | |||
| NewVal as Long | A long value that indicates the new scroll bar value in pixels. |
If the control has no scroll bars the OffsetChanged and OversizeChanged events are not fired. Use the ScrollBars property of the control to determine which scroll bars are visible within the control. Use the ScrollButtonClick event to notify your application that the user clicks a button in the control's scrollbar. Use the ScrolPartCaption property to specify the caption of the scroll's part. Use the ScrollToolTip property to specify the tooltip being displayed when the user clicks and moves the scrollbar's thumb. Use the Background property to change the visual appearance for any part in the control's scroll bar.
The following VB sample displays the new scroll position when user scrolls horizontally the control:
Private Sub Tree1_OffsetChanged(ByVal Horizontal As Boolean, ByVal NewVal As Long) If (Horizontal) Then Debug.Print "The horizontal scroll bar has been moved to " & NewVal End If End Sub
The following VC sample displays the new scroll position when the user scrolls vertically the control:
void OnOffsetChangedTree1(BOOL Horizontal, long NewVal)
{
if ( !Horizontal )
{
CString strFormat;
strFormat.Format( "NewPos = %i\n", NewVal );
OutputDebugString( strFormat );
}
}
The following VB.NET sample displays the new scroll position when the user scrolls vertically the control:
Private Sub AxTree1_OffsetChanged(ByVal sender As Object, ByVal e As AxEXTREELib._ITreeEvents_OffsetChangedEvent) Handles AxTree1.OffsetChanged
If (Not e.horizontal) Then
Debug.WriteLine(e.newVal)
End If
End Sub
The following C# sample displays the new scroll position when the user scrolls vertically the control:
private void axTree1_OffsetChanged(object sender, AxEXTREELib._ITreeEvents_OffsetChangedEvent e)
{
if ( !e.horizontal )
System.Diagnostics.Debug.WriteLine(e.newVal);
}
The following VFP sample displays the new scroll position when the user scrolls vertically the control:
*** ActiveX Control Event *** LPARAMETERS horizontal, newval if ( 0 # horizontal ) wait window nowait str( newval ) endif