Best Fit functionality

3 posts, 1 answers
  1. Thomas
    Thomas avatar
    15 posts
    Member since:
    Oct 2012

    Posted 03 Apr 2014 Link to this post

    I'm trying to use the best fit functionality for ListViews. Im using a list as the datasource like this:

    radListView.DataSource = List<Myclass>

    and in the BindingCompleted event i do the following:

                foreach (ListViewDetailColumn c in rlv.Columns)
                    c.AutoSizeMode = ListViewBestFitColumnMode.AllCells;
    The columns are not resized at all. Could you provide me with an example of how to use this feature ?

  2. Answer
    Dess avatar
    1561 posts

    Posted 08 Apr 2014 Link to this post

    Hello Thomas,

    Thank you for writing.

    RadListView has a built-in mechanism to increase or decrease the width of one or all columns in a way that makes all the text inside that column cells visible. You can enable this mechanism via the DetailListViewElement.BestFitColumns method or using ListViewDetailColumn.BestFit one. In both cases it is necessary to have data in the listview in order to obtain correct column width. Here is a sample code snippet that you may follow to fit the columns:
    public Form1()
        this.radListView1.DataSource = this.customersBindingSource;
        this.radListView1.ViewType = ListViewType.DetailsView;
    private void Form1_Load(object sender, EventArgs e)
        foreach (ListViewDetailColumn c in this.radListView1.Columns)

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


    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. DevCraft banner
  4. Thomas
    Thomas avatar
    15 posts
    Member since:
    Oct 2012

    Posted 10 Apr 2014 in reply to Dess Link to this post

    LoL, can't believe I didn't see the BestFit method itself. Thanks for the help!
Back to Top