1

I am using a UltraWinGrid and would like to have two columns under one heading. I should also note that I am doing this by adding the columns at runtime.

I cannot find anywhere in the documentation that describes what I am trying to achieve. Any help would be appreciated.

The result:

|            |     Header 1    |     Header 2    |
--------------------------------------------------
|Row 1       | Item 1 | Item 2 | Item 1 | Item 2 |
|Row 2       | Item 1 | Item 2 | Item 1 | Item 2 |
|Row 3       | Item 1 | Item 2 | Item 1 | Item 2 |

1 Answer 1

0

You can use groups to accomplish this. You will want to create a group for the first column and then groups for each of the groups of two columns. You can then hide the original headers and show only the groups.

The following code is a simple example of this:

void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
    UltraGridBand band = e.Layout.Bands[0];
    band.ColHeadersVisible = false;
    ColumnsCollection columns = band.Columns;

    UltraGridGroup group0 = band.Groups.Add("group0");
    group0.Header.Caption = "";
    UltraGridGroup group1 = band.Groups.Add("group1");
    group1.Header.Caption = "Header 1";
    UltraGridGroup group2 = band.Groups.Add("group2");
    group2.Header.Caption = "Header 2";

    columns[0].Group = group0;
    columns[1].Group = group1;
    columns[2].Group = group1;
    columns[3].Group = group2;
    columns[4].Group = group2;

}

The Create a Multiple-Row Layout Using Levels help topic also has another example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.