Currently - selecting a cell in the Grid scrolls the entire page/form to position current row's cursor on the bottom line of screen.
The form in question has many 'yes/no radio buttons followed by grid' sets, enabling the user to select yes, then TAB into the grid and add a row. (The event on the grid to support TAB-ing is included below). The user can TAB from the prior radio button, into the first cell, then after last cell in a grid, to the next radio button following grid, click yes if appropriate and do the same actions on this grid. This works great.
The problem occurs when tabbing into a grid on the bottom of the page, or even click an existing row. The bottom grid, partially out of view must trigger something in your controls that repositions the parent form to try and set the control's Active Row (which should be the entire Grid) - into focus??
This makes the page extremely difficult to use if there is content present in these rows. If you reverse tab - or even repeatedly click between the two cells on a row and the form re-positions to the bottom the row you are clicking - till any rows that were visible (i.e. 3 valid rows that were visible below current row) - no longer are.
How it should work - Given the grid has a FIXED height of 1/6th the form height (You can view 6 radio-button/grid sets always on the screen) - If I TAB into one that is partially off the form - the form should scroll the entire grid a set height above the bottom of the form - that would show the entire grid and maintain a 'minimum' margin. Entering new rows would/should make no difference to the position of the grid - as the grid itself has its own scroll bars and its content moves up the row's height - the FORM should stays where it is when a new row is added.I believe this is possible - but need an 'expert' to tell me how to do this...
I tried: Infragistics.Win.Utilities.FocusControlWithoutScrollingIntoView(grid);in the BeforeGridRowDeactivate event (since TAB is used primarily to move through grid, OnMouseDown/Up didn't seem appropriate) - with no affect.
Can you tell me what code to use to - maybe another OnEnter event item that scrolls the grid entirely into view - and something to completely disable form autoscroll on this entire form - or fix the auto-scroll to scroll parent-container(grid) into view - and not the control (row) itself. I think I have the right ideas - but have only been using 11.2 for a couple months... Really could use some help.
Thank you, Todd
Here is the TAB handler I added just in case you want to know how I did it (since older examples on the Forum did not work - and of course I wonder if you think my method is correct: add template row if not present, set focus to the first 'IsTabStop' cell - which to me implies if it is tabbable, it is visible, then set Edit mode as one of the TAB examples showed). This does work - so posted here mainly FYI...
public static void OnGridEnter(object sender, EventArgs e){ // Select first cell UltraGrid grid = (UltraGrid)sender;try { // Select first cell in grid - Is there any rows in grid
if (grid.Rows.Count == 0){ // No - activate a new row based on template grid.Rows.TemplateAddRow.Activate();}// Set the first tab into-able cell as the current active cellfor (int i = 0; i < grid.ActiveRow.Cells.Count; i++){ if (grid.ActiveRow.Cells[i].IsTabStop) { grid.ActiveCell = grid.ActiveRow.Cells[0]; break; }}// Place into edit modegrid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);}catch{ }}
Hi Todd,
I'm having some trouble understanding the situation. It's clear that you have some grids and Radio buttons on a scrollable form.
If you tab into a grid that is partially out of view, the form will scroll the grid control into view. This has nothing to do with the grid, the form does this. Three's a property on the form called AutoScroll which automatically tries to scroll the active control into view.
Todd N said:This makes the page extremely difficult to use if there is content present in these rows. If you reverse tab - or even repeatedly click between the two cells on a row and the form re-positions to the bottom the row you are clicking - till any rows that were visible (i.e. 3 valid rows that were visible below current row) - no longer are.
Here's where you lost me. This paragraph doesn't make sense. I think you are missing some words in there.
Can you post a small sample project demonstrating the issue you are having so we can check it out? I expect with something so complex, it will be impossible to assist you without a sample we can work with. There are just too many factors in play here.
(I really hate this forum editor - entered all the following, guess I typed too much - took so long I guess it timed out and page refreshed - gone, did it again - clicked preview - tried clicking video, got MS warning - clicked allow - page refreshed, gone again. third try...):
Hi Mike,
Sorry - the application is way too large for me to attempt and copy off enough to create a sample. What I did do though is copy some related code below, and capture a video of the described problem; showing the bottom with the Start button - and just a partial form so I could get in close to the grid. This is a very large form with numerous controls (textboxes, grids, drop-downs, etc. all with labels so 50 to 200 are likely added depending on form purpose), of which this section is a lot of grids, the grids are added dynamically from a parent class.
In the video I click the Yes box - then tab forward into a new box, entering 3 rows - using only the TAB key to manuver forward and backward through the grid - as you can see, going backward - as soon as I tab back from the 3rd row to the second row - the page re-scrolls to block the 3rd row from view. I go through the sequence a couple times - then you'll see the mouse - with 3 rows visible, I'll click the second row cell, then first row cells alternately - and with each click the page scrolls down until just the first row is visible - then I tried the column header - no surprise - now cannot even see the first row.
I did notice if I click yes and TAB into a barely visible grid - that as you said, the form scrolls to place 'almost' the entire box on the page, just a few pixels of the grid remain off the page. The problem is - IF the grid is remotely off the screen which it was here - the form scrolls on click. If the entire grid is visible, above the bottom of the form - then the form does not scroll at all.
This is not a show-stopper - the application can be used - but considering the users have been 'TAB'ing through these grids for years - since updating from 7.3 to 11.2 they now have to manually re-position the page at times to work on a medication table now - which is why it was sent to me.
Trivia: I did download the source for 11.2...2028 - and sorry, I forgot the line - but I found the auto-scroll function that was causing this to happen, commented it out and solve this - course, management didn't want modified 3rd party code so that solution/directory was deleted when the app was released in February.What was happening then was the following code - previously used with 7.3 - now used with 11.2 caused the entire page to scroll dramatically making it unusable - so OnGridEnter was commented out for the Feb release. Then it was realized that this code was what enabled TABing through cells - thus my fix above - redesign of this method. So - you could paste this in a sample grid app, attach it to the grid-event and see if it destroys scrolling in that app??
From the form related to Grid:
public static void OnGridEnter(object sender, EventArgs e) { UltraGrid grid = (UltraGrid)sender;
// Activate the first non-hidden cell. using (UltraGridColumn FirstNonHiddenColumn = grid.DisplayLayout.Bands[0].Columns.OfType<UltraGridColumn>().FirstOrDefault(a => !a.Hidden)) { if (FirstNonHiddenColumn != null) { grid.Rows.TemplateAddRow.Cells[FirstNonHiddenColumn.Index].Activate(); } }
grid.PerformAction(UltraGridAction.EnterEditMode); }
public static void BeforeGridRowDeactivate(object sender, System.ComponentModel.CancelEventArgs e) { UltraGrid grid = (UltraGrid)sender; int activeRowIndex = grid.ActiveRow.Index; grid.Rows[activeRowIndex].PerformAutoSize(); }
From the class that dynamically adds this grid to the form:
UltraGrid grid = new UltraGrid(); grid.Name = currentQuestion.Id.ToString(); grid.DisplayLayout.TabNavigation = TabNavigation.NextControlOnLastCell; grid.Leave += new System.EventHandler(QuestionnaireForm.OnGridLeave); grid.BeforeRowDeactivate += new System.ComponentModel.CancelEventHandler(QuestionnaireForm.BeforeGridRowDeactivate); grid.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(QuestionnaireForm.OnInitializeLayout); // Enter - used during form load to pre-enable grids if they have data - normally all grids loaded disabled grid.Enter += new EventHandler(QuestionnaireForm.OnGridEnter); // AfterCellUpdate - sets values from database grid.AfterCellUpdate += new CellEventHandler(grid_AfterCellUpdate); grid.Error += new Infragistics.Win.UltraWinGrid.ErrorEventHandler(this.OnGridError); grid.DataSource = currentQuestion.GridResponses; grid.Top = currentQuestion.AnswerYCoordinate; grid.Left = currentQuestion.AnswerXCoordinate; grid.Height = currentQuestion.AnswerHeight; grid.Enabled = questionEnabled;
section.Controls.Add(grid);
There is further processing to set cell styles based on content - I exclued thatsince technically with breakpoints in it, they never hit on this form load. The calling class uses this grid for other forms as well which may use these set cell styles. This from uses only standard text cells.