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

Automatically expand icons in ListView to fit icon content

3 Answers 152 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 31 Aug 2016, 12:59 PM

I have a ListView with the ViewTyp-property set to IconsView.

The icons contains both an image and text.

My problem is that only about 15 characters is shown in the icon. Overflowing text isn't shown.

Is there a way to automatically expand the icon size so that all the containing text is shown?

3 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Sep 2016, 09:52 AM
Hello Daniel,

Thank you for writing.  

There are two properties that provide items' size customization for all views – AllowArbitraryItemWidth and AllowArbitraryItemHeight. When both of these are set to true, the items are auto sized. Otherwise, the ItemSize is the one that determines the size of the items.
for (int i = 0; i < 10; i++)
{
    this.radListView1.Items.Add("Item that has a very long title "+i);
    this.radListView1.Items.Last().Image = Properties.Resources.Clock_Alarm;
}
this.radListView1.ViewType = Telerik.WinControls.UI.ListViewType.IconsView;
 
this.radListView1.AllowArbitraryItemHeight = true;
this.radListView1.AllowArbitraryItemWidth = true;

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

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Daniel
Top achievements
Rank 1
answered on 02 Sep 2016, 01:03 PM

Thank you! Works perfect.

However, I had changed the property AllowArbitraryItemHeight in Design time, but now I noticed it gets reset to False. When I set it programmatically it works.

Do you know why it might be reset?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Sep 2016, 02:06 PM
Hello Daniel, 

Thank you for writing back. 

I suppose that you set the ViewType property at run type but the AllowArbitraryItemHeight and AllowArbitraryItemWidth properties at design time. When you change the ViewType, both properties are reset. That is why you can either set them programmatically after setting the ViewType or set the ViewType at design time first.

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
ListView
Asked by
Daniel
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or