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
355
UltraGrid.DisplayLayout.Load() not working as expected
posted

...using Infragistics2.Win.UltraWinGrid.v9.2.dll

On FormA I have a grid named MissingGrid.  I need to open FormB with two grids (Grid1 & Grid2) and I want these two grids to be an exact copy of MissingGrid (minus the actual data).  All three grids will be bound to the same schema (new BindingList<MissingLanguageDTO>).  None of the grids have any design time schema or column collections.  In FormA I use the InitializeLayout() method to define MissingGrid. My goal was to avoid duplicating this code in two forms.

QUESTION:

How do I copy the layout, including columns, size, position, header properties, etc at runtime from one grid to another?

WHAT I'M DOING NOW:

in the constructor of FormB I'm passing the stream from the following code in FormA.  this i
private void button1_Click(object sender, EventArgs e)
        {
            MemoryStream ms = new MemoryStream();
            MissingGrid.DisplayLayout.Save(ms, UltraGrid.PropertyCategories.All);
            LanguageTabMissingPopup popupForm = new LanguageTabMissingPopup(fileKey, ms);
            popupForm.ShowDialog();
        }

In FormB I have:

protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            
            //essentially copy the grid layout from the parent form
            this.TheGridLayout.Position = 0;
            RequestGrid.DisplayLayout.Load(TheGridLayout, UltraGrid.PropertyCategories.All);
            this.TheGridLayout.Position = 0;
            ImagedGrid.DisplayLayout.Load(TheGridLayout, UltraGrid.PropertyCategories.All);

            BindGrid();
            ToggleButtons();

        }

        private void BindGrid()
        {
            ImagedGrid.SetDataBinding(new BindingList<MissingLanguageDTO>( MissingDocs.Where(m => m.IsToBeImagedToFile).ToList()), null, true);
            RequestGrid.SetDataBinding(new BindingList<MissingLanguageDTO>( MissingDocs.Where(m => !m.IsToBeImagedToFile).ToList()), null, true);
        }

When FormB opens, Grid1 & Grid2 only have 3 of the fields that are visible on MissingGrid.  My understanding is that the DisplayLayou.Load() method should bring over the grid, its columns with their configurations.

 Strangly when I break in the InitializeRow() method in FormB all of the properties are indeed set as I expect them, the grid simply is not reflecting that. Below you see that only LineNumbers is hidden.  This is as expected.

e.Row.Band.Columns.Band.Columns.All    {Infragistics.Shared.IKeyedSubObject[13]}
+        [0]    {GroupNumber}    
+        [1]    {LanguageIndicator}    
+        [2]    {State}    
+        [3]    {DateOfService}    
+        [4]    {GroupStartDate}    
+        [5]    {GroupEndDate}    
+        [6]    {LangIndStartDate}    
+        [7]    {LangIndStopDate}    
+        [8]    {LineNumbers [hidden]}    
+        [9]    {IsToBeImagedToFile}    
+        [10] {GroupDateRange}    
+        [11] {LanguageDateRange}    
+        [12] {ClaimNo}    

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    I think you need to load the layout AFTER you bind the grid instead of before. The layout will not work unless the current data structure of the grid matches the layout and if you load the layout first, the grid has no data structure at that point.

Children