FlexGrid for WinForms
ScrollPosition Property
Example 



Gets or sets the location of the auto-scroll position.
Syntax
'Declaration
 
<BrowsableAttribute(False)>
<DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)>
Public Property ScrollPosition As Point
'Usage
 
Dim instance As ScrollableControl
Dim value As Point
 
instance.ScrollPosition = value
 
value = instance.ScrollPosition
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Point ScrollPosition {get; set;}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public:
property Point ScrollPosition {
   Point get();
   void set (    Point value);
}
Remarks

Use the ScrollPosition property to get or set the scroll position using pixel coordinates.

Use the TopRow and LeftCol properties to get or set the scroll position using cell coordinates.

Example
This code binds two grids (_flexLeft and _flexRight) together and synchronizes their scrolling in the vertical direction (the user can scroll the grids independently in the horizontal direction).
// bind grids together
_flexRight.DataSource = _flexLeft;
_flexLeft.ScrollBars = ScrollBars.Horizontal;
            
// synchronize vertical scrolling 
// (this handles the AfterScroll event for both grids)
void flex_AfterScroll(object sender, C1.Win.C1FlexGrid.RangeEventArgs e)
{
    // update sender grid (could be _flexLeft or _flexRight)
    C1FlexGrid.C1FlexGrid src = ((C1FlexGrid)sender);
    src.Update();
    
    // get new vertical position from sender grid
    int y = src.ScrollPosition.Y;
    
    // apply new vertical position to the other grid
    if (src.Equals == _flexLeft)
    {
        _flexRight.ScrollPosition = new Point(_flexRight.ScrollPosition.X, y);
    }
    else
    {
        _flexLeft.ScrollPosition = new Point(_flexLeft.ScrollPosition.X, y);
    }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ScrollableControl Class
ScrollableControl Members

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback