Hi,
I have a usecase where in I have a table which has time column as one of the column. We will add rows to the UltraGrid based on time which means we should have rows in ascending of Time.
Requirements are as follows:
1. When I send start and endtimes then that grid scroll bar adjust to show these values(first row should be the start time or first row after start time).
2. Currently I have two different types of rows where I rendered them with two different colors. If I change color, how do I update this color on the row[s] without clearing the table and reload again.Please note that I am setting the fore color for a row in IntitializeRow method. It seems like it is not correct for updating the color in IntializeRow since IntializeRow will be called when a row is getting added to the table.This is different with the updating of a row color which is already present in the table.
Can anyone help me on this.
Thanks in advance,
Sanjeev.
sanjeev_reddy24 said:1. When I send start and endtimes then that grid scroll bar adjust to show these values(first row should be the start time or first row after start time).
It sounds like you want to scroll a particular row to the top of the grid. To do that, you would set grid.ActiveRowScrollRegion.FirstRow to the row you want at the top.
Thanks Mike,
That sounds like answered my first question. However i have few doubts here, how do we compare a particalur values with a column in all rows. This is because I want to find out the first row based on the given start time.(A row that has time column equal to given this value or the first row whose time column values is after the given time). Hence I can place this row at the top.
Second question is about, how do we change the fore colors of rows with out clearing the rows in grid and reinitializing them again.
Thanks,
Hi Mike,
I set the initial color for rows in a table in InitializeRowEvent itself. However I want to change this color even though none of the value in the row changed. It seems like it is not possible through InitializeRow method, since none of the value changed. Is it possible to do change this color of the row in this particular case.
Hi Sanjeev,
If nothing in the row has changed, then why is the color changing?
The reason I ask is that, if you are using InitializeRow to color the row, then you can set the appearance on the row or cell from outside of that event, but the next time InitializeRow fires, it will end up overwriting that change. So unless you are checking e.ReInitialize so that you only apply the appearance to the row the first time, that won't work.
the use case is as follows, I have a chart where I have four series in it. Two series is again represented a table, Hence I have two tables which represents these four series. And two series in the table are represented by different colors. Hence when I change the color of the series in the chart, it should update color of rows in the respective table.
For your question(overriding of default colors in InitializeRow method), I have a solution of caching these updated colors(initially set to default) and initialize them through this method whenever grid refreshes.
In a case like that where the same criteria should result in a different color, the best thing for you to do would be to re-use the Appearance object.
So create an Appearance and add it to the grid's Appearances collection. The InitializeLayout event is a good place to do this.
Then in InitializeRow, you apply that Appearance object to the cell or row as a whole. So don't set individual properties on cell.Appearance, but instead set the Appearance object itself:
// cell.Appearance.BackColor = Color.Red;
cell.Appearance = cell.Row.Band.Layout.Appearances["My Appearance"];
Then any time you want the color to change, you only have to change it on the Appearance object itself, and the grid will update any rows or cells for you automatically.
grid.DisplayLayout.Appearances["My Appearance"].BackColor = Color.Blue;
Hi I have done the coloring of tables based on series colors.
I have a doubt in scrolling of grid based on given time. As you said we have method on grid.ActiveRowScrollRegion.FirstRow to set the first row as top. I have a different use case here(I forgot to say this before, that it doesn't matter of first row in my case). I want to set the last row in scroll region, How should I do this. I haven't find any method for this.
There's no way to directly set the last row. But using the ActiveRowScrollRegion, you should be able to figure this out with a little bit of code.
You can use ActiveRowScrollRegion.VisibleRows.Count to determine the number of rows that fit in the current display. Then you just have to get the index of the row you want to be last and subtract the visible rows count from it and use the result to get the FirstRow that needs to be set in order to make the row last.