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

Header text alignment

3 Answers 470 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Lou
Top achievements
Rank 1
Lou asked on 29 Jan 2015, 09:29 PM
Hi, how do I left-align the header text in the header of the RadListView when it's set to display multiple columns? By default it's centered (see attached screenshot).

Thanks,

-Lou

3 Answers, 1 is accepted

Sort by
0
Ralitsa
Telerik team
answered on 30 Jan 2015, 09:19 AM
Hi Lou,

Thank you for contacting us. 

You need to subscribe to the CellFormatting event and set the TextAlignment property to MiddleLeft. Please take a look at the following code sample:
void radListView1_CellFormatting(object sender, Telerik.WinControls.UI.ListViewCellFormattingEventArgs e)
{
    if (e.CellElement is DetailListViewHeaderCellElement)
    {
        e.CellElement.TextAlignment = ContentAlignment.MiddleLeft;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}

In order to prevent applying the formatting to other columns' cell elements all customization should be reset for the rest of the cell elements when use the CellFormatting event. You can find more information how to customize the appearance of items in the article Formatting Items, section Formatting cells in DetailsView mode

I hope this will help. Do not hesitate to write back with further questions.

Regards,
Ralitsa
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Lou
Top achievements
Rank 1
answered on 30 Jan 2015, 02:23 PM
Thank you Ralitsa, that worked. One suggestion is to provide a well-documented property that would make this configuration easier for future users.

-Lou
0
Ralitsa
Telerik team
answered on 03 Feb 2015, 11:59 AM
Hi Lou,

I am glad to hear that my solution helps you. Thank you for your feedback, we will extend the article to show customizing of the header cells too. 

Please let me know if there is something else I can help you with.

Regards,
Ralitsa
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ListView
Asked by
Lou
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Lou
Top achievements
Rank 1
Share this question
or