Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ListView - Fixed Column Width

63 views
Skip to first unread message

Craig Petrie

unread,
Jan 7, 2004, 3:14:00 AM1/7/04
to
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


Claes Bergefall

unread,
Jan 7, 2004, 8:46:11 AM1/7/04
to
Override its WndProc and return true in response to the HDN_BEGINTRACK
notification. Don't know how to prevent the cursor from changing though.
This should work:

Imports System.Runtime.InteropServices
Public Class ListViewEx
Inherits ListView

Public Const WM_NOTIFY As Integer = &H4E
Public Const HDN_FIRST As Integer = 0 - 300
Public Const HDN_BEGINTRACKA As Integer = HDN_FIRST - 6
Public Const HDN_BEGINTRACKW As Integer = HDN_FIRST - 26
<StructLayout(LayoutKind.Sequential)> Public Structure NMHDR
Public hwndFrom As IntPtr
Public idFrom As Integer
Public code As Integer
End Structure

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_NOTIFY Then
Dim hdr As NMHDR = CType(m.GetLParam(GetType(NMHDR)), NMHDR)
If hdr.code = HDN_BEGINTRACKA OrElse hdr.code = HDN_BEGINTRACKW
Then
m.Result = New IntPtr(1)
Exit Sub
End If
End If
MyBase.WndProc(m)
End Sub
End Class

/claes


"Craig Petrie" <pet...@paradise.net.nz> wrote in message
news:%23NAvwYP...@TK2MSFTNGP10.phx.gbl...

0 new messages