This is a migrated thread and some comments may be shown as answers.

HeaderTextAlignment hides filter button

5 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brendan
Top achievements
Rank 1
Brendan asked on 26 Apr 2013, 08:55 PM
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?

5 Answers, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 30 Apr 2013, 12:35 PM
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.
0
Brendan
Top achievements
Rank 1
answered on 30 Apr 2013, 03:45 PM
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.
0
Accepted
Anton
Telerik team
answered on 06 May 2013, 07:15 AM
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.
0
Brendan
Top achievements
Rank 1
answered on 07 May 2013, 01:52 PM
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.
0
Anton
Telerik team
answered on 10 May 2013, 10:27 AM
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.
Tags
GridView
Asked by
Brendan
Top achievements
Rank 1
Answers by
Anton
Telerik team
Brendan
Top achievements
Rank 1
Share this question
or