How do I higlight a specific column in UltraWinGrid for forms? My requirement is, I search for a column in the grid, if the column is found then higlight it.
Thanks,
Vijayan
Vijayan,
In the InitializeLayout event you can set the BackColor of the CellAppearance property of the column like so:
e.Layout.Bands[0].Columns["FirstAmount"].CellAppearance.BackColor = Color.Yellow;
If you want to do it later after the grid has already been rendered on the Form, say in a Button_Click event, you could do something like this:
foreach (UltraGridColumn col in ultraGrid1.DisplayLayout.Bands[0].Columns) { if (col.Key == "SecondAmount") { col.CellAppearance.BackColor = Color.Tomato; } }
Try that and let me know if it works for you.
Michael S.
Michael,
Thanks for the reply. I tried, but this is highlighting the column but the column color stays the same.
Is there a way that the focus or the column is higlighted and when I select a cell or navigate away the column looks similar to other columns. Similat to what happens when we click on the column header, the whole column is higlighted.
Hi Vijayan,
It sounds like when you say "highlight" you mean that you want to select the column. That's what happens when the user clicks on a column header. To programmatically select a column, you would do something like this:
UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns["My Column"]; this.ultraGrid1.Selected.Columns.Add(column.Header);
Thanks Mike. That's exactly what I wanted. Appreciate your help.