I have a grid with the following 7 columns: name, cnt_a, tot_a, avg_a, cnt_b, tot_b, avg_b
I want to add a row to my header above my current column header to show a grouping of the 'a' columns and the 'b' columns. Is there a sample somewhere to show how I can do this?
Currently my header looks like this:
| Name | cnt_a | tot_a | avg_a | cnt_b | tot_b | avg_b |
I would like my header to look like this:
|----------------------------------| A | B |
| Name | cnt | tot | avg | cnt | tot | avg |
Hi,
There's nothing to it. :)
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand rootBand = layout.Bands[0]; if (rootBand.Groups.Exists("A") == false) { UltraGridGroup group = rootBand.Groups.Add("A"); rootBand.Columns["Key"].Group = group; } if (rootBand.Groups.Exists("B") == false) { UltraGridGroup group = rootBand.Groups.Add("B"); rootBand.Columns["String 1"].Group = group; rootBand.Columns["String 2"].Group = group; rootBand.Columns["Int32 1"].Group = group; rootBand.Columns["Int32 2"].Group = group; } }
I tried your response and it doesn't seem to work for me. When I used the grouping code, my header doesn't change and my column orders are out of whack. The columns i'm trying to group and not beside each other anymore after being made part of a group. I attached sample code of what i'm doing. When the columns are NOT grouped, my column order is correct. When I group the column, the column order is wrong and my header doesn't change to what I want.
I've got this figured out for what I needed.
When I use the groups, the 'e.Layout.AutoFitStyle = AutoFitStyle.ResizeAllColumns' doesn't work any more. I have the code written to resize the column I want on the SizeChanged event. How can I get the width of the scrollbar so I can deduct that from the width?
Scrollbar width is a system setting and is not controlled by the grid. So you can get it from the SystemInformation class.
SystemInformation.VerticalScrollBarWidth