Adjusting A ListView's Column Width

haroldjclements

Freshman
Joined
Jun 13, 2004
Messages
46
Hello all,

Does anyone know how to adjust the width of your columns when using a ListView object?

Code:
listView1.get_Columns().Add("Description", -2, HorizontalAlignment.Left);

For some reason I through that the ‘-2’ dictated the column width. However if I adjust this (either way) it just makes the width smaller.

Any ideas with be gratefully received.

Harold Clements
 
haroldjclements said:
Hello all,

Does anyone know how to adjust the width of your columns when using a ListView object?

Harold Clements


Hi haroldjclements,

use the following line of code:

Code:
//[0] = number of the column you wish to change
this.listView1.Columns[0].Width = 200;

You have to add columns to the listview's columns collection for this to work (if u haven't already).
See "columns" property in property window and add columns there.
 
Thanks EFileTahi-A for your response.

I don’t suppose that anyone could translate this line into J#?
Code:
listView.get_Columns
does not have a width method!

Thanks in advance,
Harold Clements
 
Sorted it :D

Rather then declare the columns and the headers together, I created a ColumnHeader object and then used the .set_Width() method.

It works fine, so I am happy.

Cheers everyone,
Harold Clements
 
Back
Top