Find listbox column in mouse move event

Is it possible to find the column number in the listbox mouse move event.

Sub MouseMove(X As Integer, Y As Integer) Handles MouseMove system.DebugLog(str(me.ColumnFromXY(x,y))) End Sub

Its not working if i am on the header. It always gives -1

Use a custom header (check Dave’s one).

Hey, you asked for a Column Number, not a Cell Header Number :wink:

It needs a little finesse but here’s a quick one:

[code]Sub MouseMove(X As Integer, Y As Integer) Handles MouseMove
Dim borderSize As Integer = 1
Dim mouseOverHeader As Boolean
#If TargetWindows
borderSize = 1 'Should really use a cached GetSystemMetrics(SM_CXBORDER) here
mouseOverHeader = If(Me.HasHeader, If((y >= borderSize) And (y <= (Me.HeaderHeight - borderSize)), True, False), False)
#ElseIf TargetMacOS
mouseOverHeader = If(Me.HasHeader, If(y < Me.HeaderHeight, True, False), False)
#ElseIf TargetLinux
'I’ll let someone else work that out if they are bored :slight_smile:

Dim col As Integer = Me.ColumnFromXY(x, If(Me.HasHeader, Me.HeaderHeight, borderSize))
system.DebugLog(“mouseOverHeader=” + str(mouseOverHeader) + " col=" + str(col))

End Sub