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
800
How to extend middle column instead of the last one?
posted

I have an UltraGrid with 3 columns, and when the grid is resized by the user, I want the 2nd column to fill the expanded space, not the last column.  I tried to do this with the answer at http://blogs.infragistics.com/forums/p/22353/81471.aspx#81471, but it doesn't work, when the grid is resized all columns remain fixed (and yes I've verified in the debugger that the 2nd column isn't getting the min/max width values set).

 

I'm using 11.1 and the answer I was using was from a couple of years ago.  Is there some different way of doing this in the newer versions, or did I just run into a bug?  If it's a bug, any workarounds I could try?

Parents
  • 469350
    Offline posted

    I tried it out and it works fine for me. I attached a sample project here demonstrating it. Try my sample and see if it works for you. If so, then something in your project is causing it not to work.

    vineas said:
    and yes I've verified in the debugger that the 2nd column isn't getting the min/max width values set

    How did you verify it? Did you check these properties at run-time to make sure your code is blowing away the settings by loading a Layout or something?

    Also... what exactly is not working about it? What behavior are you getting?

    WindowsFormsApplication39.zip
  • 800
    posted in reply to Mike Saltzman

    Sorry, it's been a long week so didn't even realize that my description of the prob was pretty much worthless, sorry about that.

    The image below shows the problem.  The 2nd column (Display Name) is the one I want to have extend, and in the first image it's the only one that isn't fixed with a min and max width.

     

    For verification, what I did was set a breakpoint in the layout to verify that the specific column wasn't set to with min/max width and then also an AfterSelectChange event I verified that the column still has the default values for min/max width (0).  The code that is setting this up is only slightly different than the code at the link I added before.  Not sure how will this will paste, but here it is:

            private void tableView_InitializeLayout(object sender, InitializeLayoutEventArgs e)
            {
                var searchColumn = GetSearchColumn();
                foreach (var band in e.Layout.Bands)
                {
                    // first, resize all the columns in the band.
                    foreach (var col in band.Columns)
                    {
                        col.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
                        // now add a bit to account for bolding when selected.
                        col.Width += (int)(col.Width * 0.15);
                        // now fix the non-search columns (so the search column is the auto-fit column)
                        if ((searchColumn != null) && (searchColumn != col))
                        {
                            col.MinWidth = col.Width;
                            col.MaxWidth = col.Width;
                        }
                    }
                }
     
                // finally, set the layout to extend the non-fixed column
                e.Layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn;
            }
    

     

     

Reply Children