Header text alignment

4 posts, 0 answers
  1. Lou
    Lou avatar
    61 posts
    Member since:
    Aug 2014

    Posted 29 Jan 2015 Link to this post

    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
  2. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 30 Jan 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Lou
    Lou avatar
    61 posts
    Member since:
    Aug 2014

    Posted 30 Jan 2015 in reply to Ralitsa Link to this post

    Thank you Ralitsa, that worked. One suggestion is to provide a well-documented property that would make this configuration easier for future users.

    -Lou
  5. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 03 Feb 2015 Link to this post

    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.

     
Back to Top