Hi,
We have recently upgraded from 2006.1 to 2012.2 winforms components.
We have an application that has a grid with card view in a child band. The card view horizontal scroll bar is not linked to the parent grid horizontal scroll bar.
I have attached an image to shows the app with card view on show.
When I double click on a cell in the card view a dialogue box appears. If I close the dialogue box, the card view H scroll bar shoots to the left.
In version 2006.1 the scroll bar stayed where it was at.
As far as I can see, the only code to have changed is:
bodBand.UseRowLayout=true; was changed to bodBand.RowLayoutStyle = RowLayoutStyle.GroupLayout;
and PlanGrid.SupportThemes=false; was changed to PlanGrid.UseOsThemes = DefaultableBoolean.False;
Has there been any changes to settings in the grid?
Thanks
David
Hi David,
From 2006 to 2012 is a pretty big jump. There have been hundreds of bug fixes and changes to the grid in that period of time. If the behavior changes, then this could be a bug in the grid, or it could also be something that was a bug and is now fixed.
I can't think of any reason why the scrollbar should be moving just from closing a dialog, though. There must be something in your code that is affecting the grid or it's data source that is triggering this. I'm afraid that I don't have any guesses as to what it might be off the top of my head. What happens when you close the dialog? What is your code doing at that point?
If you can duplicate the behavior in a small sample project and post it here, we would be happy to take a look at it and find out why it's happening.
That is a good point well made.
Separately, our upgrade from 2006 to 2012 was surprisingly smooth. Well done for not making major breaking changes between these 2 releases.
Back to my problem, I have written a small test app, but cannot replicate the problem yet.
The underlying data source is a DataSet with 2 DataTables (All within the System.Data namespace). When the dialogue box is closed (this action is clearly not the cause of the symptoms) the underlying data source is processed. The appropriate DataRow is found, and one of the cells is set to DBNull.Value.
When this happens the grid's InitializeRow event is fired. I've put a break point at the top of this and I've added Application.DoEvents() at the top, this shows that the scroll bar shoots to the left when Application.DoEvents() is fired, and not because of any code within InitializeRow.
I don't think any other event is being fired in the grid.
I cannot see any events being set to the underlying datasource.
I will continue to add the particular grid properties to my test app until hopefully I find the one that is causing my issue.
Are you using the DoEvents call just for debugging purposes? Or was it already in there? DoEvents can be very dangerous and I would recommend avoiding it's use whenever you possibly can. It can produce all sorts of timing issues and unpredictable results.
If you can't reproduce the issue by working upward from a new project, another approach that I often find useful is to work backward. Take your real application and make a copy, then start stripping it down until you have something manageable that still reproduces the issue.
davidbuchan said:the underlying data source is processed.
What kind of processing are you doing? If you are doing anything to the data source that causes a reset notification to be sent, then grid will lose it's entire layout, including the scrollbar position.
I have been able to replicate it in my test application! My mistake was where I double clicked on the grid. When I double click on the parent row, everything is ok (the scroll bar stays where it belongs). But when I click on the card view cells, the scroll bar goes to the left. (this applies to the real application as well)
I have attached the test application as a zip file. It is a Visual Studio 2010 solution referencing infragistics 2012.2.
To replicate
1. Run the application
2. Expand a row
3. Scroll the card view row to the right
4. Double click on one of the card view cells.
I have attached no initialise row events to the grid and the initialise layout only sets the card view to true.
The problem occurs immediately after the "parent.Rows[i][colIndex] = System.DBNull.Value;" (when I execute an Application.DoEvents() in visual studios immediate window)
I ran your sample and I am seeing the same issue.
When you double click on the card (child) cell, you are looping through every row in the parent table and then looking for every parent row whose first cell is a match for the Name cell in the row you clicked on. I don't think it has anything to do with the problem, but this is very inefficient. You don't need to loop. Your code can be rewritten to do the same thing like so:
void ultraGrid1_DoubleClickCell(object sender, DoubleClickCellEventArgs e) { e.Cell.Value = DBNull.Value; int colIndex = e.Cell.Column.Index; DataRow dataRow = ((DataRowView)e.Cell.Row.ParentRow.ListObject).Row; dataRow[colIndex] = System.DBNull.Value; }
Anyway, that's not the issue. I think what's happening is that changing a value in the parent row of the data source is updating the position of the CurrentlyManager to that row and this, in turn, updates the position of the child currency manager back to 0. So essentially the data source is setting the first child row active and the grid is synchronizing - activating the first card, which then scrolls that card into view.
There are a number of ways you could get around this. The easiest one is to tell the grid not to synchronize it's position with the data source:
this.PlanGrid.SyncWithCurrencyManager = false;
Unless you have other controls on the form that are bound to the same DataSource as the grid, you probably don't need to keep them in synch, anyway.
If that's not acceptable, then I'd recommend changing the parent cell value through the grid instead of going directly to the data source.
void ultraGrid1_DoubleClickCell(object sender, DoubleClickCellEventArgs e) { e.Cell.Value = DBNull.Value; int colIndex = e.Cell.Column.Index; e.Cell.Row.Cells[colIndex].Value = System.DBNull.Value; }
setting PlanGrid.SyncWithCurrencyManager = false worked perfectly.
So far I have seen no adverse effects. The application does not use Currency Manager. We only work in £ (pounds)
As for your first point, thanks for that as well. Unfortunately we have been given only enough time to do a vanilla upgrade. We're not allowed to apply things like generics or linq etc. But I'll make a note of it so we might be able to apply it in the future, and look for it elsewhere in our applications.
Cheers
Just to clarify - "currency" in this context has nothing to do with money, it refers to "current" as in the current position of the BindingManager.