Have been up all night trying to figure this one out. I am using an Infragistics.Win.UltraWinGrid.UltraGrid. The DataSource for the grid is a BindingSource that uses a custom data structure. Binding and property updates are working fine. Grid is readonly.I want to change the color (toggle) of a row if the underlying value changes. Here is a very simplified snippet of my original code using the recommended InitializeRow event (note, for simplification I am just coloring the whole row for the example, whereas actually I am coloring a cell in my application):private void ugWatchlist_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e){ if (!e.ReInitialize) return; Infragistics.Win.Appearance app1 = new Infragistics.Win.Appearance(); app1.BackColor = Color.Green; Infragistics.Win.Appearance app2 = new Infragistics.Win.Appearance(); app2.BackColor = Color.Red; if (e.Row.Appearance.BackColor.Name != Color.Green.Name) e.Row.Appearance = app1; else e.Row.Appearance = app2;}However, the color change works only once (and rows turn red on the firs t update and stay that way). According to the code, the color should toggle on each update. I can confirm in the debugger that the BackColor property is indeed changed but not reflected by the UltraGrid.Am I missing something here? I have gone through all the samples and examples and couldn't find a solution to this problem. Please help.
Hi Mike, i'm back and working on implementing this. i still have the code you sent and it does make sense. However my challenge is getting the colorizer to fire from the underlying datasource changing, as opposed to the click of a button like your example.
i cannot get the grid to pick up underlying datasource updates. i'm using a single typed BindingList with two bindingviews. and while the grid is definitely updating in realtime i'm not able to capture its events.
the only thing that i have working is hooking into the listchanged event of the underlying list and capture "ItemChanged", "ItemAdded" events. But i cannot figure out how to find those updated items in the grid.
what am i doing wrong?
performance is great. i can definitely use it here and it to my lib of cool utils. The DummyDataCreator is pretty sweet too.
thanks again
Al
So how's the performance?
I don't think the speed of adding items to the colorizer will be an issue in itself. The only time you might run into a performance issue with this code is if you end up building up a huge amount of cells in the colorizer at once.
Looping through the Cells every time the timer ticks could become an issue if you have thousands of cells in the list at once. If that's the case, I guess it might be possible to take an alternative approach where you don't process all of the cells all the time, but instead move the processing into the DrawFilter so that the cell is only processed when it has a UIElement on the screen. The problem with that approach is that the list could grow and grow and the cells that are out of view might never get cleared out, so it would end up eating memory. So there would have to be some other cleanup mechanism or a limit on the size of the list.
ok. so i took your app and added a couple of lines of code to demonstrate the volume of it "ticks". literally doing the same thing as your button is doing it but a thousand times faster. "simulating" high volume of events.
create this at the Form1 class level
Timer t1Publisher = new Timer();
//this in constructor
t1Publisher.Tick += t1Publisher_Tick; t1Publisher.Interval = 50; t1Publisher.Enabled = true;
//this is the code for the publisher_tick event
void t1Publisher_Tick(object sender, EventArgs e) { int rowIndex = DummyDataCreator.RandomInt(0, this.ultraGrid1.Rows.Count - 1); int columnIndex = DummyDataCreator.RandomInt(0, this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count - 1); UltraGridCell cell = this.ultraGrid1.Rows[rowIndex].Cells[columnIndex]; this.gridCellColorizer.AddCell(cell, Color.Red, 2000); }
i'm actually thinking of wiring up one of our existing apps to this to see how it works.
i don't think i've ever used the grid to this kind of depth. pretty wild. took me 10 minutes to figure out what the cell colorizer/timer was doing.
i do agree about the cell (actually what i wanted) and the draw filter. very smooth. but what about if the underlying data that's generated (instead of a button in this case) every second or even faster. how does that work? i.e. message pump from windows to grid gets cue'd up? how would that work in this case without having lag?