Solved

Lock Listview column width

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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