New to Telerik UI for WinFormsStart a free 30-day trial

Wrap Text in ListView's Cells

Updated over 6 months ago

Environment

Product VersionProductAuthor
2019.2.508RadListView for WinFormsDesislava Yordanova

Description

When RadListView is in DetailsView and the cell's content doesn't fit, the text is clipped:

Default behavior

This article shows how to wrap the text in order to display the whole content and ensure that the user doesn't miss any important information:

listview-textwrap-in-cells001

Text Wrap

listview-textwrap-in-cells002

Solution

Subscribe to the CellFormatting event and enable the TextWrap property of the cell element. Then, it is necessary to set the RadListView.AllowArbitraryItemHeight property to true:

Wrap ListView Cell's Text

C#

         public RadForm1()
        {
            InitializeComponent();
            this.radListView1.AllowArbitraryItemHeight = true;
        }

        private void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
        {
            e.CellElement.TextWrap = true; 
        }      
       

An alternative solution to indicate that only a part of the text is displayed in the cell elements is to show "...". In this case you can leave the AllowArbitraryItemHeight property to false and set the CellElement.AutoEllipsis property to true:

AutoEllipsis

C#

           private void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
        {
            e.CellElement.AutoEllipsis = true; 
        }  
       

AutoEllipsis

listview-textwrap-in-cells003

In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support