I am using an Ultrawingrid (Version 7.1). (An isl style file is loaded when the app opens. I need to set the following programmatically and not in the isl)
The display has some GroupByRows and DataRowsIn AfterInitializeLayout, I set the BackColor of certain rows based on a column value.Additionally, I want to set the BackColor of specific columns. I am able to loop thru the cells in the row and set it.1. Is there a direct way to set the column BackColor. I tried column.CellAppearance.BackColor, that does not work.
//Set Row color
foreach (UltraGridRow row in rowEnumerator) //DataRows) { row.CellAppearance.BackColor = ResetColor;
if (row.Cells[ColumnA].Value.ToString() == "abc") { row.CellAppearance.BackColor = NonEditColor; }
//Set Column Color
foreach (UltraGridCell cell in row.Cells) { if (if(cell.Column.Key == "month") { cell.Appearance.BackColor = MonthColor; } } }
2. I have a Save button on the form. After making changes, once I click on save, a modal window is displayed indicating data being saved.Once the grid gets back focus after the save (after modal window closes), the Row BackColor changes are retained. However, the BackColor changes on the Columns are lost.
I tried this
column.CellAppearance.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent;
That made no difference either.
Any ideas on why this might be happening?
Is there any other override required to keep the formatting done programmatically?
Thanks.
Setting it in InitializeRow for the cells in the column works the best.
Hi,
Well, it looks like the row appearance takes precedence over the column appearance. So the only thing to do is apply the appearance you want to the cells in the column instead of on the column itself.
I would use the InitializeRow event and set the Appearance no each cell in the particular column.
The Grid Layout was being reset after the save. I removed that code and it took care of the post-save formatting.
Is there a way to apply row-level formatting and column-level formatting simultaneously?
I tried something like this in AfterInitializeLayout..
}
foreach (UltraGridColumn column in band.Columns)
{
if (column.Key == "abc)
column.CellAppearance.BackColor = Color.Green;
Once I set the row-level CellAppearance, I am not able to set it at the Column level. Is there a way to do this without looping thru and setting backColor for individual cells?
Thanks,
parusiva said: 1. Is there a direct way to set the column BackColor. I tried column.CellAppearance.BackColor, that does not work. //Set Row color foreach (UltraGridRow row in rowEnumerator) //DataRows) { row.CellAppearance.BackColor = ResetColor; if (row.Cells[ColumnA].Value.ToString() == "abc") { row.CellAppearance.BackColor = NonEditColor; } //Set Column Color foreach (UltraGridCell cell in row.Cells) { if (if(cell.Column.Key == "month") { cell.Appearance.BackColor = MonthColor; } } }
1. Is there a direct way to set the column BackColor. I tried column.CellAppearance.BackColor, that does not work.
I don't see any reason why this code should not work. The cell.Appearance takes precedence over the row.CellAppearance.
This code is not very efficient, and you would probably be better off setting these appearances in the InitializeRow event, but I don't think that would cause a problem like the one you describe.
Does it work if you do not load your isl file?
Does the cell appearance work if you do not set the row.CellAppearance?
If the answer to both of those questions is no, then my best guess is that something else in your code is setting or re-setting the appearance on the cell after your loop completes.
parusiva said: 2. I have a Save button on the form. After making changes, once I click on save, a modal window is displayed indicating data being saved.Once the grid gets back focus after the save (after modal window closes), the Row BackColor changes are retained. However, the BackColor changes on the Columns are lost. I tried this column.CellAppearance.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent; That made no difference either. Any ideas on why this might be happening? Is there any other override required to keep the formatting done programmatically?
It sounds to me like your modal dialog is doing something to the data source that is causing it to send a Reset notification to the grid. When this happens, the grid throws away all of the rows and creates new one based on the new data source.
This is one of the main reasons why it's better to apply your appearances in the InitializeRow event - because this event will re-fire on every new row. It also fires any time a value in a cell changes, so it's perfect for basing the color of a row or cell on a value in that row.
Rephrasing my question...
It appears as though when I set both row.CellAppearance and column.CellAppearance, the row.CellAppearance takes precedence and the columnlevel BackColor is ignored. Is there a way to set both Row and Column level BackColor?
Thank You.