Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:35:49+00:00 2026-05-25T20:35:49+00:00

I used this http://www.devexpress.com/Support/Center/p/Q233111.aspx (the code is in VB so I converted it to

  • 0

I used this http://www.devexpress.com/Support/Center/p/Q233111.aspx (the code is in VB so I converted it to C#) to get vertical column headers. I get the vertical headers but my problem is some of them doesn’t fit, so they are not fully visible.

Is it possible to autoheight the column headers ? (all height set to max height)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:35:49+00:00Added an answer on May 25, 2026 at 8:35 pm

    As shown in Devexpress support center i think this will be the solution to your problem
    First add an helper class to your solution

    public class AutoHeightHelper
    {
        GridView view;
        public AutoHeightHelper(GridView view)
        {
            this.view = view;
            EnableColumnPanelAutoHeight();
        }
    
        public void EnableColumnPanelAutoHeight()
        {
            SetColumnPanelHeight();
            SubscribeToEvents();
        }
    
        private void SubscribeToEvents()
        {
            view.ColumnWidthChanged += OnColumnWidthChanged;
            view.GridControl.Resize += OnGridControlResize;
            view.EndSorting += OnGridColumnEndSorting;
        }
    
        void OnGridColumnEndSorting(object sender, EventArgs e)
        {
            view.GridControl.BeginInvoke(new MethodInvoker(SetColumnPanelHeight));
        }
    
        void OnGridControlResize(object sender, EventArgs e)
        {
            SetColumnPanelHeight();
        }
    
        void OnColumnWidthChanged(object sender, DevExpress.XtraGrid.Views.Base.ColumnEventArgs e)
        {
            SetColumnPanelHeight();
        }
    
        private void SetColumnPanelHeight()
        {
            GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo;
            int height = 0;
            for (int i = 0; i < view.VisibleColumns.Count; i++)
                height = Math.Max(GetColumnBestHeight(viewInfo, view.VisibleColumns[i]), height);
            view.ColumnPanelRowHeight = height;
        }
    
        private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column)
        {
            GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column];
            GraphicsInfo grInfo = new GraphicsInfo();
            grInfo.AddGraphics(null);
            ex.Cache = grInfo.Cache;
            bool canDrawMore = true;
            Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption());
            Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore);
            res.Height = Math.Max(res.Height, captionSize.Height);
            res.Width += captionSize.Width;
            res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size;
            grInfo.ReleaseGraphics();
            return res.Height;
        }
    
        Size CalcCaptionTextSize(GraphicsCache cache, HeaderObjectInfoArgs ee, string caption)
        {
            Size captionSize = ee.Appearance.CalcTextSize(cache, caption, ee.CaptionRect.Width).ToSize();
            captionSize.Height++; captionSize.Width++;
            return captionSize;
        }
    
        public void DisableColumnPanelAutoHeight()
        {
            UnsubscribeFromEvents();
        }
    
        private void UnsubscribeFromEvents()
        {
            view.ColumnWidthChanged -= OnColumnWidthChanged;
            view.GridControl.Resize -= OnGridControlResize;
            view.EndSorting -= OnGridColumnEndSorting;
        }
    }
    

    Then on your form you should make the helper class to Handle GridView’s columns resize events by adding the following lines of code

    AutoHeightHelper helper;
    private void OnFormLoad(object sender, EventArgs e)
    {
        helper = new AutoHeightHelper(gridView1);
        helper.EnableColumnPanelAutoHeight();
    }
    
    private void OnFormClosing(object sender, FormClosingEventArgs e)
    {
        helper.DisableColumnPanelAutoHeight();
    }
    

    Hope this helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
i used this example for my wcf-service: http://www.codeproject.com/KB/IP/WCFWPFChatRoot.aspx?msg=3713905#xx3713905xx But if the server stops, the
I used this article : http://www.codeproject.com/KB/WPF/InternationalizedWizard.aspx to create a WPF wizard to handle one
I used this MSDN example to construct my console host app: http://msdn.microsoft.com/en-us/library/ms731758.aspx It works
I have used this code (kind of tutorial) at http://code.google.com/p/gwt-examples/wiki/gwt_hmtl5 ... In this code,
I used this guide: http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder to be able to create my own custom UITableViewCell
I've used this tuto ( http://www.duckrowing.com/2010/03/18/documenting-objective-c-with-doxygen-part-ii/ ) to create my documentation... I would like
I'm looking to recreate the effect used on this site: http://www.brizk.com/ The site uses
Im trying to create a multilanguage website.I used this http://www.phpsimplicity.com/tips.php?id=15 tutorial and it works
I used this tutorial: http://www.helloandroid.com/tutorials/connecting-mysql-database This is performing awesome. But I got this name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.