简体   繁体   中英

UltraWinGrid Column Within a Column

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 |

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM