Solved

Lock Listview column width

Posted on 2006-07-06
5
1,557 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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