Google Grupper har inte längre stöd för nya Usenet-inlägg eller -prenumerationer. Historiskt innehåll förblir synligt.
Dismiss

ListView - Fixed Column Width

62 visningar
Hoppa till det första olästa meddelandet

Craig Petrie

oläst,
7 jan. 2004 03:14:002004-01-07
till
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

oläst,
7 jan. 2004 08:46:112004-01-07
till
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 nya meddelanden