I would like to set certain Group By row to be visible during grid initialisation. So within InitializeGroupByRow I am checking if row.ValueAsDisplayText is equal to the needed value and then perform scrolling
if ("NeededValue" == e.Row.ValueAsDisplayText){ //expand row.Expanded = true; //scroll ultraGridSubscriptionManager.ActiveRowScrollRegion.ScrollRowIntoView(e.Row); ultraGridSubscriptionManager.ActiveRowScrollRegion.FirstRow = e.Row;
}
However, the last two calls seems to be ignored.
The row is expanded but not scrolled to the first position.
The same happening if I emulate scroll using ActiveRowScrollRegion.Scroll(RowScrollAction.LineDown)
Please advise.
InitializeRow event fires as each row is initializing. So when you find the "NeededValue" the grid most likely does not yet have all of the data rows so it would be unable to scroll to the desired position. I would recommend setting FirstRow and calling ScrollRowIntoView after the grid is totally initialized. <br><br>
grid.DataSource = myDataSource;<br>
grid.ActiveRowScrollRegion.ScrollRowIntoView(theDesiredRow);<br>
grid.ActiveRowScrollRegion.FirstRow = theDesiredRow;<Br>
Thank you for suggestion. But I am talking about InitializeGroupByRow not InitializeRow. But the time InitializeGroupByRow is fired everything theoretically should be in place.
However, I will be happy to re-scroll when the grid is totally initialized. Do you know how can I identify that the grid is initialized? I was trying to re-scroll after the UltraDataSource is completly updated (the grid is more or less static from the point of the data), but by this time Grid was not ready: the GroupBy rows have not been created yet.
This is probably a timing issue. The grid is probably scrolling based on the positon of the BindingManager, and this occurs after InitializeGroupByRow has fired.
There's really no way to determine when the Initialization is "done" since it's asynchronous. What I would do is... immediately after you set the DataSource and DataMember on the grid (or call SetDataBinding), use BeginInvoke to call a method that scrolls the row you want into view. The BeginInvoke should cause enough delay for the grid to finish up whatever it was doing.
Mike
I have finished this project in February. I am sorry, but I really do not remember details now. I have done something that made the grid work, and users are now happy. I have extracted this code to show solution as I remember it. I am afraid I cannot recreate the problem now.
Sorry again.
Igor
imariash said: I have tried to call BeginInvoke for scrolling after this function. It didn't help due to the fact that the grid is initialising: I am receiving exception "Invoke or BeginInvoke cannot be called on a control until the window handle has been created"
I have tried to call BeginInvoke for scrolling after this function. It didn't help due to the fact that the grid is initialising: I am receiving exception
"Invoke or BeginInvoke cannot be called on a control until the window handle has been created"
What are you calling BeginInvoke on? The grid? I would think that the grid's Handle would have been created by the time Form_Load fires. If not, you could just as easily using BeginInvoke on the Form instead of on the grid. I know I've used that many times myself.
imariash said:However, I do not believe it is timing. I have seen scrolling working in InitializeGroupByRow (with debugger breakpoint right after the needed row was scrolled). But sometime nearer to the end of Grid update, grid just restores original scroll order (maybe by clearing ActiveRowScrollRegion? or something like this).
I'm not sure I understand what you mean here. You seem to be saying exactly the same thing I said. You are scrolling the row into view using InitializeGroupByRow, but then the grid adjusts the scrolling again afterward - this is what I meant by a timing issue.
Actually... you might even try calling BeginInvoke from inside InitializeGroupByRow, rather than Form_Load. The grid's handle must be created by that point.
If that still doesn't work, can you maybe create a small sample project demonstrating the issue so I can take a look?
Kind of
private void ultraGridBacktest_InitializeGroupByRow(RowsCollection rows, UltraGridRow row)
{
foreach (UltraGridRow row in e.Row.Rows)
this.BeginInvoke(new UpdateFixRowStatusHandle(UpdateFixRowStatus), new object[] {e.Row.Rows, row})
private void UpdateFixRowStatus(RowsCollection rows, UltraGridRow row, bool fixedRow) { try { if (row.VisibleIndex >= 0) { if (fixedRow) { if (!rows.FixedRows.Contains(row)) { row.Fixed = true; } } else { if (rows.FixedRows.Contains(row)) { row.Fixed = false; ultraGrid.DisplayLayout.RowScrollRegions[0].Scroll(RowScrollAction.LineUp); } } //reload order row.RefreshSortPosition(); } } catch(Exception ex) { } }
This code essentially moves the grid one line up in certain conditions that make row visible. But I do not remember details. Above is extract from my code. Hope it helps.
Normal 0 false false false MicrosoftInternetExplorer4
Did you manage to solve this issue as there seems to be several of us who are suffering from the same issue here, although no-one has really helped to resolve this issue,. I'd be keen to know if Infragistics have accepted that this functionality simply doesn’t work.
The whole process doesn’t seem to have been very well thought out, especially when it comes to setting scroll-bar positioning in a group-by situation.
Make
Thank you for advice. DataSource is set at the design time with UltraDataSource. My grid initialisation routine called from Form_Load is simply reading from DB row-by-row and adding rows to UltraDataSource with BeginUpdate() and SuspendRowSynchronization() at the start and ResumeRowSynchronization()/EndUpdate() in finally.
However, I do not believe it is timing. I have seen scrolling working in InitializeGroupByRow (with debugger breakpoint right after the needed row was scrolled). But sometime nearer to the end of Grid update, grid just restores original scroll order (maybe by clearing ActiveRowScrollRegion? or something like this).