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

ListView weird item height when using TextWrap

5 Answers 216 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Igor
Top achievements
Rank 2
Igor asked on 24 Jan 2014, 06:00 PM
Hi, guys

i am having issue with ListView items.
Too large text in the item does not fit into width, please see 001.png.

it can be solved by setting TextWrap = true for SimpleListViewVisualItem inherited class 

protected override void SynchronizeProperties()
      {
          base.SynchronizeProperties();
 
          Cars car = (Cars)Data.Value;
 
          this.Text = "<html><br><br><br><br><br><span style=\"color:#141718;font-size:14.5pt;\">" + car.Model + "</span>";
 
          this.element1.Text = "<html><span style=\"color:#010102;font-size:10.5pt;font-family:Segoe UI Semibold;\">" +
               "ABS:" + (car.ABS ? "<span style=\"color:#13224D;font-family:Segoe UI;\">YES" : "<span style=\"color:#D71B0E;\">NO") + "</span>" +
               "<br>ESR:" + (car.ESR ? "<span style=\"color:#13224D;font-family:Segoe UI;\">YES" : "<span style=\"color:#D71B0E;\">NO") + "</span>" + "</span>";
 
 
          this.TextAlignment = ContentAlignment.TopLeft;
          this.ImageAlignment = ContentAlignment.TopLeft;
 
          //this fixes issue from 001.png
         this.TextWrap = true;
 
      }


but, i will get the result shown on 002.png, where we have too big item height and second item does not seems to be shown correctly ("Q7" word is not shown).

I have figured out, if the string length does fit into ListViewItem width, it might miss last word of item text.
If  I disable images for ListViewItem, then i can see last word  of item text. see image 003.png


  private void listView_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            //comment this to fix last word showing
            e.Item.Image = (Image)Resources.ResourceManager.GetObject(((Cars)e.Item.Value).ImageFileName);
        }


anyway, i cannot fix first item height.

i have checked this one
http://www.telerik.com/community/forums/winforms/listview/item-height-issue.aspx
but it does not help too much.

i am using Telerik WinForms version: 2013.2.724.40

the source code project is available for download here:
http://yadi.sk/d/6Ro68KCoGfNEm

Look forward for your ideas!
Thank you! 

5 Answers, 1 is accepted

Sort by
0
Igor
Top achievements
Rank 2
answered on 24 Jan 2014, 06:38 PM
UPD:
when having TextWrap=true, and item text contains only 1 symbol, then it will not be displayed at all.
Probably this is a consequence of the thing i've explained in the very start of the topic.
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Jan 2014, 12:26 PM
Hello Igor

Thank you for contacting Telerik Support.

In order to obtain correct sizing of the items of the custom items, it is necessary to set ItemSize according to control's size and restructure the custom item to hold the whole information in the stack as it is demonstrated in our Custom items help article. Please find attached the modified sample project.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Igor
Top achievements
Rank 2
answered on 29 Jan 2014, 05:02 PM
Hi Desislava,

your solution works like a charm!
Thank you for your great help :)
0
sreeranga
Top achievements
Rank 1
answered on 11 Jan 2016, 12:50 PM

i have listview using template in kendo window 

 

iam getting problem with long text in listview item  how can i wrap text 

0
Hristo
Telerik team
answered on 14 Jan 2016, 10:23 AM
Hi Sreeranga,

Thank you for writing.

This forum thread discusses RadListView in WinForms. From you message, I understand that you might be using Kendo UI. In this case please post your question in the Kendo UI Forums.

Regards,
Hristo Merdjanov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
Igor
Top achievements
Rank 2
Answers by
Igor
Top achievements
Rank 2
Dess | Tech Support Engineer, Principal
Telerik team
sreeranga
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or