469,958 Members | 1,976 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,958 developers. It's quick & easy.

ListView - Fixed Column Width

Hi,
My client does not want users to change the width of a column in a ListView
control.

I have looked hard at properties/methods and events but can see no obvious
solution.

Does any one have a tip on how to handle this in vb.Net(2003)

Thanks
Craig
Nov 20 '05 #1
2 7327
Craig,

I did something similar for a datagrid I was using. I derived a class from
the existing datagrid as follows:

Public Class MyDataGrid
Inherits DataGrid

' Overiding these two functions will make the grid so the user cannot
resize the columns of the grid
Protected Overrides Sub OnMouseMove(ByVal e As
System.Windows.Forms.MouseEventArgs)
Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X, e.Y))
If hti.Type = DataGrid.HitTestType.ColumnResize Then
Return 'no baseclass call
End If
MyBase.OnMouseMove(e)
End Sub

Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)
Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X, e.Y))
If hti.Type = DataGrid.HitTestType.ColumnResize Then
Return 'no baseclass call
End If
MyBase.OnMouseDown(e)
End Sub

End Class

I would assume you would be able to do the same thing for the listview.....

Let me know if this works for you.

Thanks!

Jim
"Craig Petrie" <pe****@paradise.net.nz> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
Hi,
My client does not want users to change the width of a column in a ListView control.

I have looked hard at properties/methods and events but can see no obvious
solution.

Does any one have a tip on how to handle this in vb.Net(2003)

Thanks
Craig

Nov 20 '05 #2
Many thanks Jim - appreciate the reply - I will try it over the few hrs
Craig

"James Radke" <jr*****@wi.rr.com> wrote in message
news:Ok****************@TK2MSFTNGP12.phx.gbl...
Craig,

I did something similar for a datagrid I was using. ...

Jim

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mr. B | last post: by
12 posts views Thread by Dennis | last post: by
12 posts views Thread by J L | last post: by
6 posts views Thread by Maileen | last post: by
2 posts views Thread by Steve Randall | last post: by
2 posts views Thread by =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post: by
2 posts views Thread by =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.