G
Guest
Hello. I am trying to handle the event of resizing a column (if there is one). For example when I resize with the mouse a column at runtime, a label should display the new width of that column. Thank you.
* =?Utf-8?B?QW5kcmVpIFppbmNh?= said:Hello. I am trying to handle the event of resizing a column (if there
is one). For example when I resize with the mouse a column at runtime, a
label should display the new width of that column. Thank you.
Andrei Zinca said:Hello. I am trying to handle the event of resizing a column (if there is one).
For example when I resize with the mouse a column at runtime, a label
should display the new width of that column. Thank you.
Jeremy Todd said:Andrei Zinca said:Hello. I am trying to handle the event of resizing a column (if there is one).
For example when I resize with the mouse a column at runtime, a label
should display the new width of that column. Thank you.
It's tricky, but not impossible. You need to intercept the
HDN_ITEMCHANGING message sent to the ListView control. That will fire when
the columns are resized, but may also fire on other occasions (I can't
remember), so you might have to implement something to tell whether the
columns have really been resized. In any case, here's some VB code:
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Public Structure NMHDR
Public hWndFrom As IntPtr
Public idFrom As Integer
Public code As Integer
End Structure
Public Const WM_NOTIFY = &H4E
Public Const HDN_ITEMCHANGING = -320
Protected Overrides Sub WndProc(ByRef m As Message)
Dim headerInfo As NMHDR
MyBase.WndProc(m)
Select Case m.Msg
Case WM_NOTIFY
headerInfo = CType(m.GetLParam(GetType(NMHDR)), NMHDR)
If headerInfo.code = HDN_ITEMCHANGING Then [Do Whatever]
End Select
End Sub
I -think- that code is right. Let me know if it works or if you find a
problem!
Jeremy