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
465
Ultrawingrid | Align the cell contents for entire grid
posted

Hi

I understand that columns[0].cellAppearance.THAlign can be used to align text for that column. Do we have anything that 'll apply the same alignment to all the columns?

Something like Columns.CellAppearance.. instead of having to mention the column index

 

Thanks

Renu

Parents
  • 469350
    Offline posted

    Hi Renu,

    Yes, you can set this at the Band level (for just one band) or the Layout level (for all bands).You do this by using the CellAppearance property on the Override object.There's an Override property on the Band and on the DisplayLayout.

    You can even set it on all three levels if you want. The more specific setting always takes precedence over the more general one.

    So you could set a single column to be Left-Aligned, the rest of the band to be right aligned, and all other bands to be center aligned.


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

                // All bands
                ov.CellAppearance.TextHAlign = HAlign.Center;

                // Just the root band
                band.Override.CellAppearance.TextHAlign = HAlign.Right;

                band.Columns[0].CellAppearance.TextHAlign = HAlign.Center;           
            }

    There's an Appearance on the cell, too, so you could even override this on each individual cell if you wanted to. :)

Reply Children