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
5549
Center Grid/Columns when Form resize?
posted

Hi, i have a Ultragrid on my Windowsform. It has 5 Columns the Columns not fill the whole size of the Grid. Now i want center the Columns (is that possible)
and when i resize the form (the Grid hat its Property Dock set to fill) i want to center the Columns/Content .
Can you help me?

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    martin2004 said:
    Now i want center the Columns (is that possible)
    and when i resize the form (the Grid hat its Property Dock set to fill) i want to center the Columns/Content

    If you have a single-band grid, then you could center the grid content like this:


            private void CenterGridContent(UltraGrid grid)
            {
                int gridWidth = grid.Width;

                UltraGridBand band = grid.DisplayLayout.Bands[0];
                int bandWidth = band.GetExtent(BandOrigin.PreRowArea);

                int difference = gridWidth - bandWidth;
                band.Indentation = difference / 2;
            }

    Call this method from Form_Load and also from the grid_Resize event. I tried it out and it seems to work very well for me.

Children
No Data