1

我是一个 janous 网格,我在运行时设置它,我需要将标题和子标题添加到网格。标题包含两部分,一部分是一些字段,另一部分是一些字段。任何人都可以解释如何做到这一点。

在此处输入图像描述

我使用 C# windows 窗体应用程序;

        Col = new UltraGridColumn();
        Col.Caption = "Row";
        Col.Width = 10;
        Col.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center;
        Col.Key = "Row";
        Col.DataMember = "Row";
        MyGrid.Columns.Add(Col);

        Col = new UltraGridColumn();
        Col.Caption = "Name";
        Col.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center;
        Col.Key = "Name";
        Col.DataMember = "Name";
        MyGrid.Columns.Add(Col);

        Col = new UltraGridColumn();
        Col.Caption = "Family";
        Col.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center;
        Col.Key = "Family";
        Col.DataMember = "Family";
        MyGrid.Columns.Add(Col);

        Col = new UltraGridColumn();
        Col.Caption = "Address";
        Col.Key = "Address";
        Col.Width = MyGrid.Width * 18 / 100;
        Col.DataMember = "Address";
        Col.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center;
        MyGrid.Columns.Add(Col);

        Col = new UltraGridColumn();
        Col.Caption = "Tel";
        Col.Key = "Tel";
        Col.Width = 0;
        Col.DataMember = "Tel";
        Col.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center;
        MyGrid.Columns.Add(Col);
4

1 回答 1

0

您可以使用GridEXColumnSet类按您想要的方式对列进行分组。

这是代码片段:

Janus.Windows.GridEX.GridEXColumnSet CS = new Janus.Windows.GridEX.GridEXColumnSet();
CS.Caption = "Department";
CS.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center;
CS.ColumnCount = 2;
CS.Width = 200;
CS.Key = "Department";
MyGrid.RootTable.ColumnSets.Add(CS);

然后你可以通过这种方式添加你的列:

CS.Add(col1, 0, 0); // First parameter is GridEXColumn, Second is row in ColumnSet, third is col
CS.Add(col2, 0, 2);
于 2014-02-17T10:01:29.523 回答