We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use SetTopRow function

Thread ID:





28820 May 11,2005 11:12 AM UTC May 13,2005 01:05 PM UTC WinForms 3
Tags: GridControl
Hoang Dinh
Asked On May 11, 2005 11:12 AM UTC

Hi, I have an issue, Please let me know how to resolve it. I must paging my DataGrid into many pages, I using TopRowChanging event to jump to the next page. I using SetTopRow to changes the top row index and scrolls the grid. But I seem it doesn''t jump to the row I need. Below is my code //GridDataBoundGrid dgrQueryResults private void dgrQueryResults_TopRowChanging(object sender, GridRowColIndexChangingEventArgs e) { if(bAllowRaiseEvent) { //e.Cancel=true; int pos = e.Value; MessageBox.Show("Value "+pos); CurrentPostScroll = pos; //Get next row to jump. CurrentPostScroll = GetNearlyPosition(pos); this.dgrQueryResults.TopRowIndex=CurrentPostScroll-1; this.dgrQueryResults.SetTopRow(CurrentPostScroll-1); this.dgrQueryResults.InternalSetTopRow(CurrentPostScroll-1); this.dgrQueryResults.VScrollBar.Value=CurrentPostScroll-1; this.dgrQueryResults.VScrollBar.Maximum = Math.Max(CurrentPostScroll-1, this.dgrQueryResults.VScrollBar.Maximum); this.dgrQueryResults.UpdateScrollBars(); this.dgrQueryResults.Invalidate(); //CurrentCell.MoveTo(pos-1,0); } } Please help me, Thanks,

Administrator [Syncfusion]
Replied On May 11, 2005 10:42 PM UTC

I do not understand what you are trying to do. If you want to scroll the grid so rowindex 342 is at the top of the grid, then set grid.TopRowIndex = 342. The real question how does your user indicate he wants to page the grid? Does he click a button or something? If so, then in your button handler, increment or decrement grid.TopRowIndex by the ''number of rows in your page''. I do not think you what to try to call SetTopRow in the middle of TopRowChanging.

Hoang Dinh
Replied On May 13, 2005 06:57 AM UTC

Thank you, But When I set TopRowIndex value in TopRowChanged event, this event is raised again. When I drag or click on the arrow on the scrollbar, I need jump to the next page, so that I must call SetTopRow function to jump to the new page. The grid raise TopRowChanged event at least two times. How to prevent the TopRowChanged event when I call SetTopRow function. Thanks,

Administrator [Syncfusion]
Replied On May 13, 2005 01:05 PM UTC

You can avoid executing the code more than once by setting a flag.
private bool inEvent = false;
private void gridDataBoundGrid1_TopRowChanging(object sender, GridRowColIndexChangingEventArgs e)
		inEvent = true;
		this.gridDataBoundGrid1.TopRowIndex = ???;
		inEvent = false;


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon