Solved

Lock Listview column width

Posted on 2006-07-06
5
1,539 Views
Last Modified: 2008-07-11
HI All,

I'm trying to lock the widths of a listview in vb.net 2005. There is no setting on the control for this.

How can I achieve this?

Thanks,
Sean
0
Comment
Question by:nzfire
5 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 17054645
If you want to lock the widths you should use a datagrid.
0
 
LVL 9

Accepted Solution

by:
lojk earned 500 total points
ID: 17054928
Agreed a datagrid is often better but listviews have their benefits (to the users expectations at least)....

Either way this should work... Please delete the appropriate chunk as required.

    Private Sub ListView1_ColumnWidthChanging(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnWidthChangingEventArgs) Handles ListView1.ColumnWidthChanging
       
        ''either for single column locking
        Select Case e.ColumnIndex
            Case 0, 1 'ie if its the first or second column
                e.Cancel = True  'abort the event
        End Select

        'or to just prevent all resizing.
        e.Cancel = True

    End Sub
 
0
 
LVL 1

Author Comment

by:nzfire
ID: 17104332
Perfect, thanks
0
 
LVL 9

Expert Comment

by:lojk
ID: 17104393
cool, kinda reminded that i should be using a few more listviews!

happy to help, thanks for the points...
0
 

Expert Comment

by:johnhjackson
ID: 21983932
This doesn't work for me.  It prevents the viewing of the resizing, but in the end the colulmn still gets resized to any width the user wants.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question