StrataFrame Forum

Resizing listview column at run time

http://forum.strataframe.net/Topic30975.aspx

By Charles R Hankey - 2/22/2012

I have a column in a listview ( not a Stratalistview )  that may not be relevant depending on how I pull the data.  If not, I would like to set its width to 0.

I thought I could say

this.lvCompare.Columns["colMyCol"].Width = 0;

but it tells me it is not set to an instance of an object.  I tried it after the requery but no luck

In debugger I see no properties exposed at all on the columns collection. 

What's the trick.?   Anyone have an example of how to do this? 

( remember, traditional SF listview,not Stratalistview )

TIA
By Ivan George Borges - 2/22/2012

Try using its index position:

this.lvCompare.Columns[1].Width = 0;

Or I guess you could also iterate through all columns and find the one with the Header you are looking for, and then change its width.
By Charles R Hankey - 2/22/2012

Obrigado, Ivan.  I'll try that.  Saw an overload for the columnheader and thought i could get away with that. 

If index works that will be fine.
By Ivan George Borges - 2/22/2012

De nada. Wink
By Charles R Hankey - 2/23/2012

Using index worked great ! 
By Ivan George Borges - 2/23/2012

Glad to hear that! Cool