473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ListView - autosizing columns to fit data

Hi,
Does anyone have a bit of code that will auto-size the columns on a ListView
to fit the column headers AND data in those columns ?
Regards
Michael
Nov 1 '05 #1
2 3462
<msdn
url="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscolumnheaderclasswidthtopic .asp">

.... The ColumnHeader can be set to adjust at run time to the column contents
or heading. To adjust the width of the longest item in the column, set the
Width property to -1. To autosize to the width of the column heading, set
the Width property to -2.

</msdn>

However, you have to do the above for every column by looping through the
column collection.

"ASGMikeG" <AS******@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
Hi,
Does anyone have a bit of code that will auto-size the columns on a ListView
to fit the column headers AND data in those columns ?
Regards
Michael
Nov 1 '05 #2
Many thanks - that gets me most of the way there !.

"Siva M" wrote:
<msdn
url="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscolumnheaderclasswidthtopic .asp">

.... The ColumnHeader can be set to adjust at run time to the column contents
or heading. To adjust the width of the longest item in the column, set the
Width property to -1. To autosize to the width of the column heading, set
the Width property to -2.

</msdn>

However, you have to do the above for every column by looping through the
column collection.

"ASGMikeG" <AS******@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
Hi,
Does anyone have a bit of code that will auto-size the columns on a ListView
to fit the column headers AND data in those columns ?
Regards
Michael

Nov 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Kevin Westhead | last post by:
Can anyone confirm whether or not there are any limits imposed on the widths of autosized columns in a list-view. I've found that the autosizing appears to have an upper limit, i.e. it will not...
1
by: Mamatha | last post by:
Hi I have one application ,that diplays data from database into the listview control.While adding data to the listview i want to display an icon to the leftside of the first column's data.Here...
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
2
by: ASGMikeG | last post by:
Hi, Does anyone have a bit of code that will auto-size the columns on a ListView to fit the column headers AND data in those columns ? Regards Michael
0
by: Terry Brown | last post by:
I have a form which contains a listview item. The form is created to view data that is generated by interaction with a separate form. There are buttons on the form that change the data source...
3
by: Martin Panggabean | last post by:
Hello All, I've kind a logic problem ... I want to fill the listView control in VB.NET with data in my mySql table using Datareader object component. But It seems that the way of how listView...
5
by: John Devlon | last post by:
Hi, Does anyone know how to get a value of a second column of a selected item in Listview. I've create a listview and added this code Listview.Items.Clear() Listview.Columns.Clear()...
1
by: =?Utf-8?B?THluYkBtcy5jb20=?= | last post by:
I have a executable winforms application I would like to change. I use quite a number of listview controls in my main form. I dump about 15 columns of data into a couple of listviews. This data...
3
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
When I set a label to span 2 columns of a 2-column TableLayoutPanel, set both of these plus the containing form to AutoSize, then at runtime fill in the label, the autosizing does not take the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.