GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / SetHScrollBarPosition Method
The new horizontal coordinate, in pixels, where the horizontal scrollbar is to be moved. If this value is out of the expected range, the toolkit sets the current value to the nearest one, means minimum or maximum one.
Example





In This Topic
SetHScrollBarPosition Method (GdViewer)
In This Topic
Sets the required position of the horizontal scrollbar, in pixels, related to the document currently displayed in the GdViewer control. In other words, the horizontal scrollbar moves to the newly specified coordinate on the horizontal axis. This coordinate relates to the actual document area of the currently displayed page.

The ScrollViewer event is raised if the scrollbar has moved.

Syntax
'Declaration
 
Public Sub SetHScrollBarPosition( _
   ByVal NewPos As Integer _
) 
public void SetHScrollBarPosition( 
   int NewPos
)
public procedure SetHScrollBarPosition( 
    NewPos: Integer
); 
public function SetHScrollBarPosition( 
   NewPos : int
);
public: void SetHScrollBarPosition( 
   int NewPos
) 
public:
void SetHScrollBarPosition( 
   int NewPos
) 

Parameters

NewPos
The new horizontal coordinate, in pixels, where the horizontal scrollbar is to be moved. If this value is out of the expected range, the toolkit sets the current value to the nearest one, means minimum or maximum one.
Remarks
Please note that if the newly specified value is out of the expected range, the toolkit sets the current value to the nearest one (means minimum or maximum one) without reporting any error. Otherwise, you can regularly apply the GetStat method to determine if this method has been successful.

Just to remind you, that this coordinate is 0-based with the origin being in the top left corner in the document pages area and it is related to the current page determined by the CurrentPage property.

Be aware that the ScrollViewer event is raised only if the scrollbar has really moved.

Example
How to set the new position of the scrollbars.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
            
    'The current position of both scrollbars after displaying the document
    'according to your currently defined GdViewer control settings.
    Dim x As Integer = GdViewer1.GetHScrollBarPosition()
    Dim y As Integer = GdViewer1.GetVScrollBarPosition()
    MessageBox.Show("The scrollbars are set to this position: " + x + ", " + y, "GdViewer.SetHScrollBarPosition")
            
    If (x <> 0) OrElse (y <> 0) Then
        'Setting the scrollbars to the required position.
        GdViewer1.SetHScrollBarPosition(0)
        GdViewer1.SetVScrollBarPosition(0)
        MessageBox.Show("The scrollbars are now set to this position: 0, 0", "GdViewer.SetHScrollBarPosition")
    End If
            
    'Do your other stuff here.
    GdViewer1.CloseDocument()
Else
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetHScrollBarPosition")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    //The current position of both scrollbars after displaying the document
    //according to your currently defined GdViewer control settings.
    int x = GdViewer1.GetHScrollBarPosition();
    int y = GdViewer1.GetVScrollBarPosition();
    MessageBox.Show("The scrollbars are set to this position: " + x + ", " + y, "GdViewer.SetHScrollBarPosition");
            
    if ((x != 0) || (y != 0))
    {
        //Setting the scrollbars to the required position.
        GdViewer1.SetHScrollBarPosition(0);
        GdViewer1.SetVScrollBarPosition(0);
        MessageBox.Show("The scrollbars are now set to this position: 0, 0", "GdViewer.SetHScrollBarPosition");
    }
            
    //Do your other stuff here.
    GdViewer1.CloseDocument();
}
else
{
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.SetHScrollBarPosition");
}
See Also