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
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");
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
Screenshot
I will have a look at this. Thanks!
One question regarding this. When I use this sample code, I understand that I am actuallt hiding my existing column headers and adding new ones instead.
The problem is that I am loosing all the standard formatting of the headers. Should it be like that.
I am using the Infragistics Appstyling and everything just becomes plain...
/H
Hi Zlatan,
There's no reason why the Application Style Library should no affect any column headers. But I tried this out using Georgi's sample and I get the same results.
This is because the new header is not a column header - it's a Group Header. And the isl file that I picked (IG.Isl) apparently doesn't style the group headers. So what you have to do is modify your isl and update the GroupHeader role with the same appearance as the ColumnHeader role.
Mike, you don't have any idea where this gap comes from...?
Hi Henrik,
I'm not sure. It looks like it's just the way to the layout comes out when you have groups. I doubt there is anything you can do to change that.