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.
OK!
Is there any way to do this merge operation directly on the column headers, instead of these "group headers"?
What I want to do is to merge two columns into one, nothing else. I have a UltraCombo with two columns...
My software makes it possible to use all isl files available, and then I will have to modify all of them...
Hello Zlatan,
You could use ColumnLayout instead , this will allows you to create column header which overlaps columns that you should merge, so the Application Style Library will style this header correctly and you should note that this what be the same as using of groups. And I still believe that Mike approach is better, you should managed the isl file instead to change your code . Changes in code involves a lot of testing and they hides some risk. So if I were on you I defiantly will use Mike’s approach.
I hope that this will helps you.
Alright, I have proceeded according to Mike's suggestion and it works almost as planned.
I found the Group Header in the .isl file and I simply cloned every setting I found.
The red arrow shows a "white" gap between the grey border and the group header. How can I get rid of that?
I tried to modify the labelInsets but without success. They were already on zero.
However, I have one small question left.