The following two lines of code cause flickering (text jumps from black to white to black again).
row.Band.Layout.Grid.DisplayLayout.Override.ActiveRowAppearance.Reset();row.Band.Layout.Grid.DisplayLayout.Override.ActiveRowAppearance.ForeColor = Color.Black;
Is there some way of telling the row NOT to redraw itself immediately after the Reset()?
I was trying BeginUpdate/EndUpdate on the grid level, but that is for data changes.
Hi,
kennethknoepfli said:I was trying BeginUpdate/EndUpdate on the grid level, but that is for data changes.
This is not correct. BeginUpdate and EndUpdate are specifically to tell the control not to paint. They have nothing to do with changes to the data.
I ran your sample and I see that there is a tiny flicker sometimes when I click on the George Harrison row. But I don't see a problem on any other row.
The reason for the flickering is that the row is activated and selected before the MouseDown event fires. So the row is getting highlighted and then you change the color.This explains why BeginUpdate/EndUpdate did not help - because you were probably calling BeginUpdate in the MouseDown event and it is already too late by then.
SuspendLayout will not help at all, since that method is related to laying out child controls and has nothing to do with what you are doing.
I'm not really sure exactly what you are trying to do here or why you are chaning the ActiveRowAppearance. Do you need to apply a different appearance to the ActiveRow based on some other factor? Your sample is not doing that, but maybe you are doing it in your real application?
If not, then you only need to set the ActveRowAppearance once, you don't need to keep setting it over and over every time the active row changes.
If that's no good, then maybe you should be using the Before/AfterRowActivate events to deal with this instead of MouseDown. MouseDown doesn't really make sense anyway, because the user could change the active or selected rows via the keyboard. Of course, your comments here mention drag and drop, so maybe that's no good either.
It's hard to offer you any more useful advice without knowing exactly what your requirements are.
>> This is not correct. BeginUpdate and EndUpdate are specifically >> to tell the control not to paint. They have nothing to do with changes to the data.
Thank you for the correction, I'd confused them with similarly named calls from a different programming environment.
>> The reason for the flickering is that the row is activated and >> selected before the MouseDown event fires... in the MouseDown event >> {and} it is already too late by then.
Ah, that was important to learn. That explains it.
>> maybe you should be using the Before/AfterRowActivate events to deal >> with this instead of MouseDown.
Yes! I have now moved the Active Row color change code to BeforeRowActivateand it works without flickering. Thank you. Problem solved.
>> I'm not really sure exactly what you are trying to do here >> or why you are chan(g)ing the ActiveRowAppearance.
OK, I'll explain what I am doing in case others may be in a similar situation.
There are two grids representing two boxes with electrical terminals.
The moment the user presses MouseDown in one grid, each row in that gridis scanned. * If it already is connected, it is set to LightGray.* If it is not yet connected, the color is Reset (black text, white background)* And if the ActiveRow is already connected, I set the font to black.
On the second grid, * terminals electrically compatible with the Active Row are LightGreen, * electrically compatible but already connected ones are (dark)Green, * electrically incompatible but not yet connected ones are LightGray,* and unconnected incompatible ones I just Reset.
But because the concept of an Active Row is meaningless in the second grid,I manipulate the second grid's ActiveRow appearance, too, to give the illusionthere is no ActiveRow.
The user can now make a connection with Drag and Drop, or leave the mouse and study the colors to decide what to do next.
And if the user presses MouseDown in the *second* grid, the roles of the grids are reversed and the rows are recolored.
I hope that wasn't too much information :)