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
1540
UltraWinGrid Bands - Copy Information
posted

Hello.

I've added to my UltraWinGrid a DataSource. It creates me two Bands, Band[0] and Band[1].

On my grid I want to show the information about Band[0] and one Column of Band[1] on the same level. I need to "copy" the info of the Band's[1] column to my band[0].

Is it possible?

Thank you.

Best regards,

Maria

  • 469350
    Offline posted

    Hi Maria,

    Yes, I'm sure you can do this and it should be very easy. The only question I have is... what happens if there is more than one child row under a particular parent row?

    Assuming that your data source only has one child row for each parent row, then you could achieve what you want by adding an unbound column to band 0.


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridBand band = layout.Bands[0];

                if (false == band.Columns.Exists("My unbound column"))
                {
                    UltraGridColumn column = band.Columns.Add("My unbound column");                
                }           
            }

    Then you use the InitializeRow event to read the data from the child row and populate the cell in the parent row:


            private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
            {            
                // if the unbound column has not been added to the grid, yet, then just bail out.
                if (false == e.Row.Cells.Exists("My unbound Column"))
                    return;

                // Is this the root band?
                if (e.Row.Band.Index == 0)
                {
                    e.Row.Cells["My unbound Column"].Value = e.Row.ChildBands[0].Rows[0].Cells["Whatever Cell I want"].Value;
                }
            }