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
470
Multiline Column Headers
posted

Couldn't find an answer to this, sorry in advance if it's already answered!

I want to make my ultragrid column headers multiline, then wordwrap the header text over these lines.  So far I have found .DisplayLayout.Bands(0).ColHeaderLines = 2 which gives me 2 lines but can see how to wordwrap the text over these 2 lines.


ie instead of "Customer Name" you would have

"Customer

Name"

Thanks

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    If you want to control where the text breaks, then you would change the caption on the column to include a line break.


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

                band.ColHeaderLines = 2;
                band.Columns["Customer Name"].Header.Caption = "Customer " + Environment.NewLine + "Name";
            }

    If you want the grid to just wrap the text whenever needed based on the width of the column, and you don't particularly care where the text breaks, you could do this:


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

                ov.WrapHeaderText = DefaultableBoolean.True;
                band.Columns["Customer Name"].Header.Caption = "Customer Name";
            }

Children