Hi,
I have two rows in the root collection of my grid. Due to some layout requirements I have to adjust the row height to the same row height as another grid has.
If I set the row height of grid.Rows[0] = 32, the row height of the second row also changes. The AfterRowResize-Event will only be called for the row I change the height, but the height of both rows has changed.
It looks like a bug, or do I something wrong here? The grid is bound to a UltraDataSource. I'm using version 11.1.2011.2030.
Regards
Markus
Yes, I see how this might be very difficult to track down.
So just to make sure I understand, you want the rows in both grids to have their heights synchronized. Are you also synchronizing the scrolling the grids? If so, then another approach you might take is to use the UIElements of the grid. This would essentially size the rows every time the grid paints, but it would be limited to the rows that are in view, so it would be pretty fast. This approach will probably be very tricky if you are synchronizing in both directions, though. You would need some kind of anti-recursion flag.
The basic idea would be to create a CreationFilter for your grid and trap AfterCreateChildElements. You would watch for when the 'parent' parameter is a RowUIlement. From there, you could get the row and use the height of the RowUIElement to adjust the corresponding row in the other grid.
Hello Mike,
I know the Refresh-method, but the problem is to know when to use it. After setting each property!? Do you have a list of properties they change the row height after changing the property value? I guess you have not!
And the problem with the color of a cell is even more tricky: Seting the color of a cell in band 1, the row in band2 gets resized. Therefore I have to reinitialize all rows that can contain multiline text and I don't know which of those are actually resized!
Other approaches?
Hi Markus,
It seems I was mistaken about the InitializeRow event firing when a column is shown. The event will fire when a new column is adding, but it doesn't respond to a column being hidden or shown.
If the column is hidden or shown by the user, via the ColumnChooser, then the Before/AfterColPosChanged event will fire, though. So maybe you could use that event - depending on how the column is being shown.
If you are setting the height of the row inside InitializeRow, and you are performing some operation that does not cause that event to fire (such as setting the color of a cell), then you could force the event to fire by calling:
this.ultraGrid1.Rows.Refresh(RefreshRow.FireInitializeRow);
Hello again,
I have still problems with the row height in some scenarios. It seems not to have any logic that I can recognize when a row gets resized and the events AfterRowResize or InitializeRow are NOT fired (see pics attached).
I show you two cases of this:
1) After showing a column row gets resized and NONE of the events mentioned above get fired. In cases like this (new columns, rows etc.), I can do resize in the way we discussed so far in this thread. It's a poor solution because not all of the rows have text to be resized and all rows in the grid have to be looped instead the grid fires events.
2) After setting the backcolor of cell in the AfterCellActivate-event, the row resizes and NO event is fired. Code:
this.GridStandard.DisplayLayout.Override.ActiveAppearancesEnabled = DefaultableBoolean.True;
this.GridStandard.DisplayLayout.Override.ActiveCellAppearance.BackColor = this.GridStandard.ActiveCell.Appearance.BackColor != Color.Empty ? this.GridStandard.ActiveCell.Appearance.BackColor : Color.White;
I can not resize my rows after setting of each grid-property because it seems not to have any logic and NO events are fired.
What can I do?
Perhaps you could use the InitializeRow event in that case. It will fire when the column visibility changes as well as any time the value of a cell is changed.