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.
ok let me check if again it wont work than i'll get back to you.
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.
Hi,
This is not exists. i Changed many names but every time i'm getting same error.
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.
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;
}