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
180
WinGrid Multi Row Column Header Layout
posted

OK.  I need some help.  I am trying to set up a grid that looks something like this:

 

 In the InitializeLayout event I have code to set up the columns based on my Typed Dataset:

        private void gridVDCF_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)

        {

            UltraGridBand band = e.Layout.Bands[0];

 

            int headerPosition = 0;

 

            band.Columns[WorkViewAccountsConstants.COL_DAY].Header.Caption = "";

            band.Columns[WorkViewAccountsConstants.COL_DAY].Width = 75;

            band.Columns[WorkViewAccountsConstants.COL_DAY].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_DAY].CellActivation = Activation.NoEdit;

           

            band.Columns[WorkViewAccountsConstants.COL_VALUE_DATE].Header.Caption = WorkViewAccountsConstants.DISP_VALUE_DATE;

            band.Columns[WorkViewAccountsConstants.COL_VALUE_DATE].Width = 100;

            band.Columns[WorkViewAccountsConstants.COL_VALUE_DATE].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_VALUE_DATE].CellActivation = Activation.NoEdit;

 

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_AC].Header.Caption = WorkViewAccountsConstants.DISP_ACCOUNT_CURRENCY;

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_AC].Width = 100;

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_AC].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_AC].CellActivation = Activation.NoEdit;

 

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_USD].Header.Caption = WorkViewAccountsConstants.DISP_USD;

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_USD].Width = 100;

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_USD].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_USD].CellActivation = Activation.NoEdit;

 

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_AC].Header.Caption = WorkViewAccountsConstants.DISP_ACCOUNT_CURRENCY;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_AC].Width = 100;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_AC].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_AC].CellActivation = Activation.NoEdit;

 

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_USD].Header.Caption = WorkViewAccountsConstants.DISP_USD;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_USD].Width = 100;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_USD].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_USD].CellActivation = Activation.NoEdit;

 

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_AC].Header.Caption = WorkViewAccountsConstants.DISP_ACCOUNT_CURRENCY;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_AC].Width = 100;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_AC].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_AC].CellActivation = Activation.NoEdit;

 

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_USD].Header.Caption = WorkViewAccountsConstants.DISP_USD;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_USD].Width = 100;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_USD].Header.VisiblePosition = headerPosition++;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_USD].CellActivation = Activation.NoEdit;

 

        }

Then I call a method to set up the groups:

        private void SetupGrid()

        {

            UltraGridBand band = this.gridVDCF.DisplayLayout.Bands[0];

 

            //Arrange the band's column in Group Layout style

            band.RowLayoutStyle = RowLayoutStyle.GroupLayout;

 

            UltraGridGroup firstGroup = band.Groups.Add("FirstGroup", "Committed Credits");

            UltraGridGroup secondGroup = band.Groups.Add("SecondGroup", "Committed Debits");

            UltraGridGroup thirdGroup = band.Groups.Add("ThirdGroup", "Value Date Committed Funds");

 

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_AC].RowLayoutColumnInfo.ParentGroup = firstGroup;

            band.Columns[WorkViewAccountsConstants.COL_CREDITS_USD].RowLayoutColumnInfo.ParentGroup = firstGroup;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_AC].RowLayoutColumnInfo.ParentGroup = secondGroup;

            band.Columns[WorkViewAccountsConstants.COL_DEBITS_USD].RowLayoutColumnInfo.ParentGroup = secondGroup;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_AC].RowLayoutColumnInfo.ParentGroup = thirdGroup;

            band.Columns[WorkViewAccountsConstants.COL_COMMITTED_USD].RowLayoutColumnInfo.ParentGroup = thirdGroup;

 

        }

 

I want the non-grouped columns to appear first, but the grid puts the grouped columns first and the non-grouped columns at the end.  Also, I would like the column headers of the non-grouped columns to span vertically - like in the graphic, the ValueDate column is taller.

As a starting point I used this sample:

http://help.infragistics.com/NetAdvantage/WinForms/2010.3/CLR2.0/?page=WinGrid_Grouping_Columns_in_Row_Layout_using_code.html

I feel that I almost got it.  I just need a little assistance to get it to look like I want it to.

Thanks!

 

 

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    adrian_maull said:
    I feel that I almost got it.  I just need a little assistance to get it to look like I want it to.

    Yep, it sounds like you are almost there.

    To arrange the columns and groups in the order you want, you use the OriginX property on the RowLayoutColumnInfo or RowLayoutGroupInfo.

    The spans of every object default to 2x2, so in a case like this, you will probably want to use multiples of 2 for your OriginX values. Or, you could set the SpanX and SpanY on each object to 1 to make things a little easier.

    So let's assume you do this the cleaner way and you loop through every column and set it's RowLayoutColumnInfo.SpanX and SpanY to 1.

    Then you would set the OriginX on the "Value Date" column to 0. On the "Committed Credits" group, you would set the OriginX to 1 (since the span of the previous column is 1). The "Committed Credits" is two columns wide, to the next OriginX would be 3 so the OriginX of the "Committed Debts group would be 3. And so on down the line. 

    To make the "Value Date" column span the height of the groups, you would need to set it's SpanY to 2 (one for the group header and one for the column headers within the groups).

Reply Children