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

No ImageAlignment Property for column's header

3 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phi
Top achievements
Rank 1
Phi asked on 02 Nov 2010, 09:02 PM
I tried to put nice graphics together with the column's header but the result does not impressed me at all. The image is too far away from the text that it looks very odd! See attached picture!

RadButton has a ImageAlignment property that I could use to move the image closer to the text. There is not such a property here that I could see.

Phi

3 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 03 Nov 2010, 09:09 AM
Hello,

There is an image alignment property for the columns header, but you have to access is in a different way, but it won't yield the results you are looking, for, you can access it using the ViewCellFormatting event, like so:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridHeaderCellElement)
    {
        e.CellElement.ColumnInfo.ImageLayout = ImageLayout.Zoom;
        e.CellElement.ColumnInfo.HeaderImage = Properties.Resources.calendar;
        e.CellElement.ColumnInfo.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
 
        e.CellElement.ImageAlignment = System.Drawing.ContentAlignment.MiddleCenter;
        e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText;
    }
}
But this will cause an overlay of the image...

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
Phi
Top achievements
Rank 1
answered on 03 Nov 2010, 03:13 PM
I just don't understand the design concept here!!! Adding image to column's header should be a basic thing for a grid. Why would you even need to attach to an event for this!!!

Phi
0
Jack
Telerik team
answered on 09 Nov 2010, 04:49 PM
Hello Phi,

Yes, most of the properties can be set directly when accessing the column, for example:
this.radGridView1.Columns["Name"].HeaderImage = Resources.red;
this.radGridView1.Columns["Name"].HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.radGridView1.Columns["Name"].TextImageRelation = TextImageRelation.ImageBeforeText;

However, the ImageAlignment property is not exposed at the column level and that is why you have to handle ViewCellFormatting event. We want to keep our API clean and simple and that is why we do not expose all cell properties. RadGridView contains many cell types, which enable setting different visual properties. The preferred way to customize the cell appearance is using formatting events. Nevertheless, if you have any ideas on how to improve our API, we will appreciate them and we will consider these ideas when planning our future versions.

Should you have any other questions, do not hesitate to ask.

Kind regards,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Phi
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Phi
Top achievements
Rank 1
Jack
Telerik team
Share this question
or