PC Review


Reply
Thread Tools Rate Thread

datagrid scrolling...capturihng rows displayed in view of datagrid

 
 
Patrick
Guest
Posts: n/a
 
      4th Jun 2004
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.
 
Reply With Quote
 
 
 
 
ClayB [Syncfusion]
Guest
Posts: n/a
 
      4th Jun 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      6th Jun 2004
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]" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.

 
Reply With Quote
 
ClayB [Syncfusion]
Guest
Posts: n/a
 
      7th Jun 2004
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

"Patrick" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message

news:<(E-Mail Removed)>...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrolling DataGrid's selected row out of view selects next control Brian Tkatch Microsoft VB .NET 3 7th Jul 2006 08:35 PM
How do you map DataGrid rows to it's DataSource when sorting a DataGrid? aualias Microsoft Dot NET Framework Forms 2 13th Sep 2005 06:09 PM
How to get subset of rows displayed in current page of DataGrid? =?Utf-8?B?Q2Fyb2x5biBWbw==?= Microsoft C# .NET 3 8th Aug 2005 12:22 PM
restricting # of rows displayed in a datagrid or datalist wh1974 Microsoft ASP .NET 2 6th Aug 2004 09:47 AM
DataGrid Component | Displaying columns of a DataSet as Rows in a DataGrid ? Diego TERCERO Microsoft C# .NET 3 19th Dec 2003 02:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:07 AM.