Solved

Lock Listview column width

Posted on 2006-07-06
5
1,503 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now