Hi,
I have a problem with a WinGrid (NetAdvantage 2007) :
I have rows, that are grouped by one or more fields.At the beginning all groups are collapsed. I expand manually some of them.Then I have a function that changes the aspect of some rows based on rules : row.Appearance.BackColor = System.Drawing.Color.White;row.Appearance.BackColor2 = System.Drawing.Color.DarkGray;row.Appearance.BackHatchStyle = BackHatchStyle.BackwardDiagonal;The problem is that when the appearances are applied, all groups get collapsed again.I want them to remain in the same state (expanded or collapsed) as they were before the "appearance change"...
Is it a bug ? It may have been corrected in newer versions of NetAdvantage, but I cannot just update my version, I'm stuck with the 2007 one...I image I could check the state of each group, store it somewhere, apply my appearances, and then restore the state of each group afterwards, but it seems like too much to do for this...
Thanks in advance,Philippe.
For those interested here's what I did :
Before calling the function causing the reset, I store the state of all the GroupByRows in a Dictionnary (called GroupByRowsState, storing the Value of the GroupByRow, and the Expanded state).I also add a callback on the "InitializeGroupByRow" event.
In the callback I only set the Expanded state if it exists, so as not to interfere too much :if (GroupByRowsState.ContainsKey((string)e.Row.Value)){ e.Row.Expanded = GroupByRowsState[(string)e.Row.Value]; GroupByRowsState.Remove((string)e.Row.Value);}
And it seems to work perfectly as of now.
re-rechecked, and yes the Expanded field in the UltraGridGroupByRow is correct...So that's what I'll do : store the state of all GroupByRows, and then restore it after the screen refresh.
Thanks for your insight.
Indeed, it must be a reset notification sent from the app (there's a third party API that I use), because the datasource is read again after the action I'm doing.
So my only option is now to get all the groups that are expanded/collapsed, and restore the state of the app.
My next question is : how can I know which rows are expanded or collapsed ? I check the following fields, but they do not seem to be the good ones because they are set to "false" even when the group is expanded (I checked at debug time) :in UltraGridrow : Expanded, HasExpansionIndicator, IsExpanded, and also ShowAsExpanded in a sub-hierarchy...
Hi Philippe,
There's no way that setting an appearance could ever cause a row to be collapsed. I suspect there must be some other peice of code that is doing this.
Most likely, you are doing something which is causing your grid's DataSource to send a Reset notification which means that the grid has to throw away all of the rows and create new ones based on the new data.
The only way around that is to either avoid the reset, or try to store the state of the grid rows before the reset and then restore it afterward. But without knowing exactly what you are doing, it's hard to offer you any more useful advice.