Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2745
Merge column headers in code
posted

Hello!

I would like to merge two column headers into one. I am not binding my datasource at design time so I guess that I need to merge the headers in code?

I found a lot of posts about this topic but everything seems to deal with this in design time.

What can I do?

/Henrik

Parents
No Data
Reply
  • 53790
    posted

    Hello Henrik,

    Here is small sample:

       ultraGrid1.Dock = DockStyle.Fill;

     

                DataTable dt = new DataTable();

                dt.Columns.Add("Column 1");

                dt.Columns.Add("Column 2");

                dt.Columns.Add("Column 3");

     

                dt.Rows.Add("1", "2", "3");

                dt.Rows.Add("1", "2", "3");

     

                ultraGrid1.DataSource = dt;

     

                UltraGridBand band = ultraGrid1.DisplayLayout.Bands[0];

                band.RowLayoutStyle = RowLayoutStyle.GroupLayout;

     

                UltraGridGroup group = band.Groups.Add("MyGroup", "MyGroup");

     

                band.Columns["Column 1"].RowLayoutColumnInfo.ParentGroup = group;

                band.Columns["Column 2"].RowLayoutColumnInfo.ParentGroup = group;

     

                band.Columns["Column 1"].RowLayoutColumnInfo.PreferredCellSize = new System.Drawing.Size(0, 18);

                band.Columns["Column 1"].RowLayoutColumnInfo.SpanX = 2;

                band.Columns["Column 1"].RowLayoutColumnInfo.SpanY = 4;

     

                band.Columns["Column 2"].RowLayoutColumnInfo.PreferredCellSize = new System.Drawing.Size(0, 18);

                band.Columns["Column 2"].RowLayoutColumnInfo.SpanX = 2;

                band.Columns["Column 2"].RowLayoutColumnInfo.SpanY = 4;

     

     

                band.Columns["Column 3"].RowLayoutColumnInfo.PreferredCellSize = new System.Drawing.Size(0, 18);

                band.Columns["Column 3"].RowLayoutColumnInfo.PreferredLabelSize = new System.Drawing.Size(0, 48);

                band.Columns["Column 3"].RowLayoutColumnInfo.SpanX = 2;

                band.Columns["Column 3"].RowLayoutColumnInfo.SpanY = 4;

     

    Please take a look on attached sample for more details

    UltraGridRowLayoutCustom.zip
Children