I am trying to detect when the mousecursor is near the right edge of either column 0 or column 1 in a Listbox
on only the first 3 rows
Sub MouseMove(X As Integer, Y As Integer) Handles MouseMove
Const tolerance=8
Dim w As Integer
Dim i As Integer
coldrag=(-1)
w=0
If y<=Me.RowHeight*3 Then
For i=0 To 1
w=w+Me.Column(i).WidthActual // <-------------- THIS IS ALWAYS ZERO, when in fact the listbox (ME) has 8 columns all > 100px wide
// It does in fact get here
If x>=(w-tolerance) And x<=(w+tolerance) Then
colDrag=i
Exit For
End If
Next i
End If
If colDRAG>=0 Then
Me.MouseCursor=System.Cursors.SplitterEastWest
Else
Me.MouseCursor=System.Cursors.StandardPointer
End If
End Sub
Dave, i tried your code with a few small changes and i get the right values (on Windows 10). I have a label below the listbox that gives the accumulated values of the columnwidths and it shows the exact values even if i resize columns. Here is the code i tried:
[code]Const tolerance = 8
Dim w As Integer
Dim i As Integer
Dim coldrag As Integer
coldrag = (-1)
w = 0
If y <= Me.RowHeight * 3 Then
For i = 0 To Me.ColumnCount - 1
w = w + Me.Column(i).WidthActual // <-------------- THIS IS ALWAYS ZERO, when in fact the listbox (ME) has 8 columns all > 100px wide
Label1.Text = str(w)
// It does in fact get here
If x >= (w - tolerance) And x <= (w + tolerance) Then
colDrag = i
Exit For
End If
Next i
End If
If colDRAG >= 0 Then
Me.MouseCursor = System.Cursors.SplitterEastWest
Else
Me.MouseCursor = System.Cursors.StandardPointer
End If
[/code]