Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Merged cells in RowLayout mode
posted

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. 

 

Parents
No Data
Reply
  • 975
    posted

    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");

    1. You can then assign each Column to a particular Group.

      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;

    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
    
     

     

Children