Automatically expand icons in ListView to fit icon content

4 posts, 1 answers
  1. Daniel
    Daniel avatar
    2 posts
    Member since:
    Aug 2016

    Posted 31 Aug Link to this post

    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?

  2. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 02 Sep Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Daniel
    Daniel avatar
    2 posts
    Member since:
    Aug 2016

    Posted 02 Sep in reply to Dess Link to this post

    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?

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 02 Sep Link to this post

    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.
Back to Top