Hello,
I'm trying to create a grid with 2 lines of headers, like the following:
|--------------------------- column 1 ---------------------------|
|--- column 2 ---| |--- column 3 ---| |--- column 4 ---|
Now, I understand that for this to work, I need to activate RowLayout mode, which is fine. The problem is that I also want to merge the rows of data in the grid, and as soon as I set the RowLayout to place columns on a 2nd header row, the merge no longer works for data rows. In fact, I've placed a custom MergedCellEvaluator on the columns and I can tell by putting a break point in it's ShouldCellsBeMerged function that it's not even called at all when the RowLayout is spread on multiple header rows.
It's important to mention, also, that in my example, column 1 is a LabelOnly unbound column. So, in this case, it remains logical for the data rows to be merged, even if the header is spread on 2 rows.
Any suggestions as to how to make this work would be greatly appreciated. As it stands, I'm forced to look into faking a RowLayout using 2 bands stuck together, which is a bear to make work, and probably won't function as expected.
Thank you for you help.
This is an old post, but maybe someone will need the info.The OP was trying to merge data cells, as well as header columns, but all I wanted to do was create a header with 2 rows, so I could show that groups of adjacent columns were related under a super header. Here's the code I found to help me, from the "Developer's Guide ->Using WinGrid ->Formatting and Appearance->Formatting Rows
UltraGridBand b = this.customersUltraGrid.DisplayLayout.Bands[0];UltraGridGroup theNameGroup = b.Groups.Add("Name");UltraGridGroup theAddressGroup = b.Groups.Add("Address");UltraGridGroup thePhoneGroup = b.Groups.Add("Phone");
this
"Name"
"Address"
"Phone"
In Visual Basic:
b.Columns("CompanyName").Group = theNameGroup b.Columns("ContactName").Group = theNameGroup b.Columns("ContactTitle").Group = theNameGroup b.Columns("CustomerID").Group = theNameGroup b.Columns("Address").Group = theAddressGroup b.Columns("Country").Group = theAddressGroup b.Columns("City").Group = theAddressGroup b.Columns("Region").Group = theAddressGroup b.Columns("PostalCode").Group = theAddressGroup b.Columns("Phone").Group = thePhoneGroup b.Columns("Fax").Group = thePhoneGroup
"CompanyName"
"ContactName"
"ContactTitle"
"CustomerID"
"Country"
"City"
"Region"
"PostalCode"
"Fax"
In C#:
b.Columns["CompanyName"].Group = theNameGroup; b.Columns["ContactName"].Group = theNameGroup; b.Columns["ContactTitle"].Group = theNameGroup; b.Columns["CustomerID"].Group = theNameGroup; b.Columns["Address"].Group = theAddressGroup; b.Columns["Country"].Group = theAddressGroup; b.Columns["City"].Group = theAddressGroup; b.Columns["Region"].Group = theAddressGroup; b.Columns["PostalCode"].Group = theAddressGroup; b.Columns["Phone"].Group = thePhoneGroup; b.Columns["Fax"].Group = thePhoneGroup;
theAddressGroup.Header.Appearance.TextHAlign = HAlign.Center;thePhoneGroup.Header.Appearance.TextHAlign = HAlign.Center;
thePhoneGroup.Header.Appearance.TextHAlign = HAlign.Center;
The example goes on, which you'd do if you want to
group the data rows too, but this is all you need to create the two header rows.
Bill
Hi Bill,
Can you explain this in detail I m trying to do the same. But not able to do that completely. Do you have any sample which can be used.
How do we align the header rows to come as
|--col 1--| |--col 2--||--col 3--|
|--------------col 4-----------------|
Thanks