ListView Resize Column Headers

TexG

Regular
Joined
Apr 2, 2003
Messages
88
Location
San Antonio Texas
Hi all,

I hve this code here that works great for resizing the columns in a listview control.

Problem is i new to .Net and i havent figured out how to acces this public sub Resizer from a class or module with the call to Resizer(). Also finding it very hard to get access to a form when i am in a class or module.

I have seen lots or answers on the forum that say i need to do a
Dim myform as New Form1

is this dim statment opening up another form?
Anyways thanks for the help and hope the code resizer helps someone else out.


Code.....

Public Sub Resizer()

Dim ColumnHeaderResize As ColumnHeader

For Each ColumnHeaderResize In ListView1.Columns

ColumnHeaderResize.Width = -1

Next

End Sub
 
When you open a form, you need to store the instance of said form
for later. You can no longer just do 'Form2.Show' or whatever, as
you need to declare an instance. So, in a class, you might do
Visual Basic:
Public Shared frm As New Form1()
Then, to show the form, you would do
Visual Basic:
frm.Show()
and frm would be what you use
to access Form2; not the Form2 classname itself.

If there is a public sub in a class, you need to declare a new instance
of the class to access it. If the class was named 'MyClass' then,
Visual Basic:
'invalid
MyClass.MyMethod()

'valid
Dim mc As New MyClass()
mc.MyMethod()
unless the method in the class is decared with the Shared
keyword, in which case
Visual Basic:
MyClass.MyMethod()
is valid, and no instance of the class
is needed.

[edit]Fixed typo[edit]Gah! Fixed typo in my 'fixed typo' message.[/edit][/edit]
 
Last edited:
Back
Top