How to get ListVew visible items count?

  • Thread starter Thread starter Tomislav Bartolin
  • Start date Start date
T

Tomislav Bartolin

Hi all,

I need to get a number of visible items currently displayed in a
ListView control(number of items visible without scrolling).
One solution might be calculating the number of items by using single
item's Font.Height property and view's ClientSize.Height property, but
this just doesn't seem right.
Can someone provide a better solution?

Thanks
 
Public Const LVM_FIRST As Integer = &H1000
Public Const LVM_GETCOUNTPERPAGE As Integer = LVM_FIRST + 40
Public Overloads Declare Auto Function SendMessage Lib "User32.dll" (ByVal
hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam
As Integer) As Integer

Dim visibleCount As Integer = SendMessage(myListView.Handle,
LVM_GETCOUNTPERPAGE, 0, 0)

/claes
 
Back
Top