Hello friends, i neew your help i have a datatable with this struct.
But i need change de backcolor of a cell that has the max and min value of each column
1) How i can do this??
2) hoy i can show at the end of the grid one row whith the max value for each colum
Tanks
Hi,
I'm not sure I understand your question, but it sounds like you want to color a row or a cell based on a value in that row. That's easy to do using the InitializeRow event. There is some sample code that shows how to do this in the most efficient way in the WinGrid Performance Guide.
Take a look at the last section called "Re-Use Appearances"
Thanks for the reply it works perfect.One last question, as I can do to make when grouping the grid also changes the color according to the grouping, for example in the form load of the grid is loaded with information the range of a week, and I want to group by day, then I shows the summaries by day, but I want to change back the color of the maximum and minimum valor only the day not the whole week.
To add a summary, you just use the band.Summaries.Add method. There are lots of overloads to this method, but in your case, you probably want to use one that takes a Key so you can use the key to refer to the summary easily.So you will probably want to build the key of your summary dynamically using the column name as part of the key.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridColumn column = band.Columns["Int32 1"]; band.Summaries.Add("SUM" + column.Key, SummaryType.Sum, column); }
Thanks, it i sthat i want, but please can you helpme with an example of how the summaru should add in the InitializeLayout
You are making this far too complicated, I think.
Here's some sample code:
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { foreach (UltraGridCell cell in e.Row.Cells) { if (cell.Column.Key.StartsWith("Tem")) { double cellValue = (double)e.Row.GetCellValue(cell.Column); double summaryValue = (double)e.Row.ParentCollection.SummaryValues["key of the summary I created for this column"].Value; if (cellValue == summaryValue) cell.Appearance.BackColor = Color.Red; else cell.Appearance.ResetBackColor(); } } }
The key you pass in to the SummaryValues indexer is the key of the summary that you created when you created the summary for the column. The InitializeLayout is usually a good place to create your summaries, and when you use the Summaries.Add method, you should specify a key. In this case, you probably want the summary to be some combination of the key of the column with some extra text like "max" or "min" so that way you can generate the summary name from the column name inside the InitializeRow event.