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

How to get Columns to AutoSize FILL in RadListView

7 Answers 852 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 02 Nov 2017, 07:40 PM

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.

7 Answers, 1 is accepted

Sort by
0
Jhon
Top achievements
Rank 1
answered on 02 Nov 2017, 11:56 PM
Estimated mark,
Use the bestfit property of the columns.

column.columns (i) .bestfit()


regards
0
Jhon
Top achievements
Rank 1
answered on 02 Nov 2017, 11:57 PM
foreach (ListViewDetailColumn c in this.radListView1.Columns)
    {
        c.BestFit();
    }
0
Jhon
Top achievements
Rank 1
answered on 02 Nov 2017, 11:57 PM
foreach (ListViewDetailColumn c in this.radListView1.Columns)
    {
        c.BestFit();
    }
0
Dimitar
Telerik team
answered on 03 Nov 2017, 07:14 AM
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.
0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 03 Nov 2017, 12:24 PM

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.

0
KKL
Top achievements
Rank 1
answered on 13 Feb 2018, 10:45 AM
Hi, Mark. I know this is probably a bit late, but I'd encourage you (and anyone else keen for this functionality) to keep tabs on this feedback item. Hopefully if more interest is shown this property will be added soon. 
0
Dimitar
Telerik team
answered on 13 Feb 2018, 12:26 PM
Hi,

Yes, voting for a particluar item will increase its priority. However, I cannot provide a timeframe for this one. Please follow the item and you will be notified when its status changes. 

Do not hesitate to contact us if you have other 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.
Tags
ListView
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Jhon
Top achievements
Rank 1
Dimitar
Telerik team
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
KKL
Top achievements
Rank 1
Share this question
or