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

Scroll view in MDI

Thread ID:





33666 Aug 24,2005 05:32 AM UTC Aug 24,2005 10:07 AM UTC WinForms 5
Tags: GridControl
Administrator [Syncfusion]
Asked On August 24, 2005 05:32 AM UTC

I have an MDI application. I am using gridcontrol in the forms. I have multiple forms open in the application. In a form (say Form1) i have a gridcontrol with nearly 1000 rows. When i select a particular cell (say 10th row) in the grid and scroll down the view to an area where the selected cell is not visible (say 250-300th row), and move to another tab(or Form2 or Form3) in the application and come back to the form(Form1), the view shows the selected cell(10th row) instead of the scrolled view (250-300th row).

Administrator [Syncfusion]
Replied On August 24, 2005 07:31 AM UTC

I tried to see this in our \Essential Studio\\Windows\Grid.Windows\Samples\Quick Start\GridPad sampple. What I see is that when the form with the grid gets focus, the grid will try to display the last current cell. So, if you actually click a cell in the 250-300 range, when you come back to this form, I would expect the cell that you clicked be made visible. If you do not click the cell, then when you go back to the form, the grid will scroll so the last clicked cell is visible. If this is the problem you are trying to avoid, you could try explicitly calling grid.CurrentCell.MoveTo when you go to another form and move teh current cell to grid.TopRowIndex and grid.LeftColIndex if teh currentcell is not visible when you leave teh grid. Am I missing something? Can you see the problem you are having in the GridPad sample? Is your grid a GridControl? If it is a GridDataBoundGrid bound ot a DataTable, then something changing the position of teh CurrencyManager might affect how the grid is scrolled. Are you handling events like CurrentCellActivalting or CurrentCellMoving? These also may affect the which cell has focus. Are you doing anything special, like setting the currentcell, when you go back to the form? If you can upload a sample showing the problem, we probably can suggest a solution.

Administrator [Syncfusion]
Replied On August 24, 2005 08:48 AM UTC

Clay I am using GridControl in my application (MDI). In a form I click on a cell and am scrolling down the view.But I am not clicking any cell when i scroll down to the area where the clicked cell is not visible. Then i move to the next tab(form) and then come back to the form the view shows the clicked cell. Instead the view should be in the area where I last scrolled down. (Where i didnt click any cell).

Administrator [Syncfusion]
Replied On August 24, 2005 09:29 AM UTC

If you want to maintain the scolled position without clicking a cell on the scrolled page, then you will have to either change the currentcell or reset the scroll position. The reason is that .NET scrolls any container window to show the last active control. In a grid, this means that it scrolls the grid to show the last active cell. One way to avoid this is to handle the grid''s leave event and make teh currentcell be visible on the last scrolled page. private void grid1_Leave(object sender, EventArgs e) { this.grid1.CurrentCell.MoveTo(this.grid1.TopRowIndex, this.grid1.CurrentCell.ColIndex); }

Administrator [Syncfusion]
Replied On August 24, 2005 09:49 AM UTC

Clay, Thanks for the solution. But I do not want to move the current cell. Only the view should show the last scrolled page. (the currentcell should be the cell that i last clicked.) I do not want to change the current cell programmatically. Kindly let me know if any other alternate solution exists.

Administrator [Syncfusion]
Replied On August 24, 2005 10:07 AM UTC

The only way I know to do this would be to let the grid paint with the way the framework scrolls it, and then recroll it back to where you want it. This requires a timer and can result in an occassional flash as the grid redraws. You would handle both the Enter and Leave events.
private int lastTopRow = -1;
Timer t;
private void grid1_Enter(object sender, EventArgs e)
	if(t == null)
		t = new Timer();
		t.Interval = 20;
		t.Tick += new EventHandler(t_Tick);

private void grid1_Leave(object sender, EventArgs e)
	lastTopRow = this.grid1.TopRowIndex;

private void t_Tick(object sender, EventArgs e)
	this.grid1.TopRowIndex = lastTopRow;


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

or the page will be automatically redirected to 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