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
Hi,
my requriment is same please tell me how to design grid like this....
|--col 5--| |--col 6--||--col 7--|
|--------------col 8-----------------|
In this code it is giving run time error every time that is "Key is already exists".
i'm doing that code in InitializeLayout event.
Please help.
My Code is:-
private
void ultraGrid2_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
UltraGridBand b = this.ultraGrid2.DisplayLayout.Bands[0];
UltraGridGroup theBlankGroup = b.Groups.Add("Employee Status"); // (here it is giving error)
UltraGridGroup theLegalStatusGroup = b.Groups.Add("Legal Hold Status");
theBlankGroup.Header.Appearance.TextHAlign =
HAlign.Center;
theLegalStatusGroup.Header.Appearance.TextHAlign =
b.Columns[
"Emp_Id"].Group = theLegalStatusGroup;
"Name"].Group = theLegalStatusGroup;
"DOB"].Group = theLegalStatusGroup;
"Salary"].Group = theBlankGroup;
}
Make sure the group does not already exist before you add it. My guess is that the InitializeLayout event is firing more than once and the second time, you are trying to add a group that is already there.
This is not exists. i Changed many names but every time i'm getting same error.
That error message clearly indicates that you are attempting to add a group with a key that already exists. There's no other reason why you should ever get that error message on that line of code.I would try rewriting the code like this:
UltraGridGroup theBlankGroup;if (b.Groups.Exists()) theBlankGroup = b.Groups["Employee Status"];else theBlankGroup = b.Groups.Add("Employee Status");
If that still doesn't work, then perhaps you could post a small sample project demonstrating the error.
ok let me check if again it wont work than i'll get back to you.