HeaderTextAlignment hides filter button

6 posts, 1 answers
  1. Brendan
    Brendan avatar
    68 posts
    Member since:
    Dec 2011

    Posted 26 Apr 2013 Link to this post

    If I set the gridview columnheader.text alignment to middle right when using ExcelType filtering, it overlays the filter button image.  How can I avoid this?
  2. Anton
    Admin
    Anton avatar
    167 posts

    Posted 30 Apr 2013 Link to this post

    Hi Brendan,

    Thank you for writing.

    In order to assist you for this case I need more information about what you expect to happen with the filter button. Are you expecting this button to hide or to be moved on another place? If you want the filter button to be rearranged where it should be? 

    Thank you in advance for your cooperation. I am looking forward to your reply.

    All the best,
    Anton
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. Brendan
    Brendan avatar
    68 posts
    Member since:
    Dec 2011

    Posted 30 Apr 2013 Link to this post

    In my app I am formatting grids based on column contents, so numbers would be right aligned.  I notice now that that works fine.  However, I allow the user to switch themes on the fly.  That's where the problem seems to crop up.

    In the left side of attached png, you can see the effect of changing the theme on an existing grid, the text overlays the filter 'funnel' icon.  The right hand of the png shows the header text correctly as the grid was just created. 

    To clarify, the text overlays the icon when the theme is changed.  This happens with every theme I tried.
  4. Answer
    Anton
    Admin
    Anton avatar
    167 posts

    Posted 06 May 2013 Link to this post

    Hello Brendan,

    Thank you for writing back.

    In order to achieve the desired layout, you should following these steps:

    1. Create your custom header cell element that inherits GridHeaderCellElement. In this custom cell you should add new element that will be display the text. Arrange this element on the desired place by overriding the ArrangeOverride method. Consider following example:
    public class CustomHeaderElement : GridHeaderCellElement
    {
        private LightVisualElement Text;
     
        public CustomHeaderElement(GridViewColumn column, GridRowElement row)
            : base(column, row)
        {
            this.Text.Text = base.Text;
            base.DrawText = false;
        }
     
        protected override void CreateChildElements()
        {
            this.Text = new LightVisualElement();
            this.Text.ShouldHandleMouseInput = false;
            this.Children.Add(Text);
     
            base.CreateChildElements();
        }
     
     
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(GridHeaderCellElement);
            }
        }
     
     
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            base.ArrangeOverride(finalSize);
            PointF TextLocation = new PointF(finalSize.Width - this.Text.DesiredSize.Width - 15, (finalSize.Height - this.Text.DesiredSize.Height)/2);
            RectangleF TextRec = new RectangleF(TextLocation, this.Text.DesiredSize);
            this.Text.Arrange(TextRec);
            return finalSize;
        }
    }

    2. Subscribe to the CreateCell event and set the CellType of the header cells to be your custom header element, for example:
    void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
    {
        if (e.CellType == typeof(GridHeaderCellElement))
        {
            e.CellType = typeof(CustomHeaderElement);
        }
    }

    Attached is a sample project that demonstrate how the code above works. 

    Should you have any other questions, I will be glad to assist you.

    Regards,
    Anton
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  5. Brendan
    Brendan avatar
    68 posts
    Member since:
    Dec 2011

    Posted 07 May 2013 Link to this post

    Thank you Anton for the lengthy reply.  Is it your opinion that the solution you propose should be needed or is the overlay considered a bug?

    I may try to implement what you have proposed, or just do something simpler - center align.
  6. Anton
    Admin
    Anton avatar
    167 posts

    Posted 10 May 2013 Link to this post

    Hi Brendan,

    Thank you for writing back.

    The described behavior is not a bug, this is a case that you need to manually arrange the elements according to your needs. There are different layout requirement from our clients for this case, however it is not possible to automatically arrange the elements to cover all cases.

    Also, it is not possible to cover all clients needs by creating properties for all possible cases. Instead, we are supporting different mechanisms like the CreateCell event to allow our users to customize the behaviors/layouts of our controls according their needs.

    If you have further questions, feel free to write back.

    Greetings,
    Anton
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Back to Top