Try this.
1) add a member to your form.
private VScrollBar gridVScrollBar = null;
2) In FormLoad, after the DataSource has been set on the grid, loop through
the grid's controls to save its vertical scrollbar, and subscribe to its
scroll event.
foreach(Control c in this.dataGrid1.Controls)
{
if(c is VScrollBar)
{
this.gridVScrollBar = c as VScrollBar;
break;
}
}
if(this.gridVScrollBar != null)
this.gridVScrollBar.Scroll += new
ScrollEventHandler(this.dataGrid1_Scroll);
3) In the handler you can get the limits.
private void dataGrid1_Scroll(object sender, ScrollEventArgs e)
{
if(e.Type == ScrollEventType.EndScroll)
{
Console.WriteLine("{0} to {1}",
this.gridVScrollBar.Value, this.gridVScrollBar.Value +
this.dataGrid1.VisibleRowCount -1);
}
}
==================================
Clay Burch, .NET MVP
Visit
www.syncfusion.com for the coolest tools
[quoted text, click to view] "Patrick" <pboor@tcfleasing.com> wrote in message
news:54212853.0406060505.7b361ccf@posting.google.com...
> Thanks for your reply though as I had indicated, I am not selecting a
> row. I want to be able to capture the top row and the bottom row when
> the user scrolls. Thanks...
>
>
>
>
> "ClayB [Syncfusion]" <clayb@syncfusion.com> wrote in message
news:<ubDFuBhSEHA.1764@TK2MSFTNGP10.phx.gbl>...
> > Maybe the technique described in this FAQ can be used.
> >
> > George Shepherd's Windows Forms FAQ contains an entry entitled:
> >
> > How do I find the top-left visible cell in a datagrid?
> >
> > Check it out at:
> >
http://www.syncfusion.com/faq/winforms/search/880.asp > >
> > =============================================
> > Clay Burch, .NET MVP
> >
> > Syncfusion, Inc.
> > visit
http://www.syncfusion.com for .NET Essentials
> >
> >
> > "Patrick" <pboor@tcfleasing.com> wrote in message
> > news:54212853.0406031839.7c5124fe@posting.google.com...
> > > I have a datagrid on a property tab sheet. Lets say that the grid
> > > contains 50 rows with 12 displaying on the first page. For this
> > > example lets say the user scrolls down to record 3 and records 3-14
> > > display. The user clicks off to another tab and comes back. They do
> > > not select anything on the grid. I want to remember when they come
> > > back to scroll to position 3 at the top through 14 on that page. I
> > > know how to handle this if a record is selected on the grid but that
> > > is not the case in this example. I was looking at the paint method to
> > > get the rows and the scroll event but I don't know how to capture the
> > > rows displayed in the view of the grid. Is there a proper sequence of
> > > events to capture which rows are in view? Any overriden methods I
> > > should be using? Thanks for your help.