How to get Columns to AutoSize FILL in RadListView

6 posts, 0 answers
  1. Mark
    Mark avatar
    75 posts
    Member since:
    Oct 2014

    Posted 02 Nov Link to this post

    Have a list view with multiple columns.  Is there a way to get the columns to AutoSize similar to a RadGridView of "FILL".  I have not found anything yet.  

     

    Thanks for the help.

  2. Jhon
    Jhon avatar
    18 posts
    Member since:
    Jun 2017

    Posted 02 Nov in reply to Mark Link to this post

    Estimated mark,
    Use the bestfit property of the columns.

    column.columns (i) .bestfit()


    regards
  3. Jhon
    Jhon avatar
    18 posts
    Member since:
    Jun 2017

    Posted 02 Nov in reply to Mark Link to this post

    foreach (ListViewDetailColumn c in this.radListView1.Columns)
        {
            c.BestFit();
        }
  4. Jhon
    Jhon avatar
    18 posts
    Member since:
    Jun 2017

    Posted 02 Nov in reply to Mark Link to this post

    foreach (ListViewDetailColumn c in this.radListView1.Columns)
        {
            c.BestFit();
        }
  5. Dimitar
    Admin
    Dimitar avatar
    1996 posts

    Posted 03 Nov Link to this post

    Hi Mark,

    This functionality is not available in RadListView, however, you can easily implement a similar one. For example, you can use the Resize event to set the column width:
    private void RadListView1_Resize(object sender, EventArgs e)
    {
        int columnWidth = radListView1.Width / radListView1.Columns.Count;
        foreach (var item in radListView1.Columns)
        {
            item.Width = columnWidth;
        }
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Mark
    Mark avatar
    75 posts
    Member since:
    Oct 2014

    Posted 03 Nov Link to this post

    Yes, I know about BestFit(), but this doesn't do what I want it to.  I have my columns set to a specified min width size. So, these columns will fit perfectly when the form is set to it min size.  When I resize the form, my control resizes as well, however, unlike a GRID's columns that has an AutoSizeMode.FILL, which will resize the columns so they fill the control (no dead space on the right side of the control).  However, as I discovered and Dimitar pointed out, this functionality doesn't exists for a ListBox control. Yes, BestFit will resize the columns based on the AutoSizeMode of the control (which can be based on the header, cell contents, both or none), it will not FILL the control, therefor, leaving ugly dead space in the control.   I believe Dimitar's solution will work. I am going to try that out.

Back to Top