Hi,
I have an ultragrid bound to a datasource which will be updated frequently
(i.e. changes are all done through the data source). When this occurs
I get the grid to refresh the relevant row but I would also like it to "flash" the row for a few seconds.
i.e. Change the back colour of the row to green for 1-2 seconds and then turn it back to white
(or whatever). I have tried a few ways such as using a timer to revert the colour back after 2 seconds,
or using a thread pool thread to revert the colour after sleeping for 2 seconds. These dont work very well.
For example, sometimes the row does not flash at all.
Can you recommend a good way of doing this? Does the grid provide any features to support this?
thanks
It's hard to determine why the row wouldn't be flashing in some situations and not others, unless you're somehow overriding that row's Appearance. The simplest way to accomplish this, in my opinion, is to use a Timer's Tick event and set the Appearance of the relevant rows to a pre-existing Appearance object, then either clearing the Appearance or using a different object when you need to turn off the 'flash'. The reason for using a single Appearance object is that it would be very inefficient to constantly recreate appearance objects, or to have each row create a new Appearance when they will all look identical.
The quick sample code that I used is:
private Infragistics.Win.Appearance flashAppearance;private Infragistics.Win.Appearance FlashAppearance{ get { if (this.flashAppearance == null) { this.flashAppearance = new Infragistics.Win.Appearance(); this.flashAppearance.BackColor = Color.Green; } return this.flashAppearance; }}bool showRowHighlight = false;private void timer1_Tick(object sender, EventArgs e){ try { this.ultraGrid1.BeginUpdate(); foreach (UltraGridRow row in this.ultraGrid1.Rows) { if (this.showRowHighlight) row.Appearance = this.FlashAppearance; else row.Appearance = null; } this.showRowHighlight = !this.showRowHighlight; } finally { this.ultraGrid1.EndUpdate(); }}
-Matt