listview - determining nbr of visible rows

  • Thread starter Thread starter txplayboy2002
  • Start date Start date
T

txplayboy2002

Is there a way in vb.net to determine the number of rows that can be
visible in the listview region ? Not the total # rows in the
listview, but only the visible count.

Also, I was wondering if there was a way to determine from a given
ListViewItem, whether or not it is currently visible in the region.

Thanks,
Mark
 
For each item, you can retreive the Bounds, this will return the item's
rectangle, you then need to compare this with the client area to see if it
is visible.

HTH

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
There is the EnsureVisible method (this will scroll a listitem into view,
but not tell you if it was visible to begin with).

Greg
 
Is there a way in vb.net to determine the number of rows that can be
visible in the listview region ? Not the total # rows in the
listview, but only the visible count.

Also, I was wondering if there was a way to determine from a given
ListViewItem, whether or not it is currently visible in the region.

Public Const LVM_FIRST As Integer = &H1000
Public Const LVM_GETCOUNTPERPAGE As Integer = LVM_FIRST + 40
Public Const WM_SETREDRAW As Integer = &HB


Public Enum LVS_EX
LVS_EX_GRIDLINES = &H1
LVS_EX_SUBITEMIMAGES = &H2
LVS_EX_CHECKBOXES = &H4
LVS_EX_TRACKSELECT = &H8
LVS_EX_HEADERDRAGDROP = &H10
LVS_EX_FULLROWSELECT = &H20
LVS_EX_ONECLICKACTIVATE = &H40
LVS_EX_TWOCLICKACTIVATE = &H80
LVS_EX_FLATSB = &H100
LVS_EX_REGIONAL = &H200
LVS_EX_INFOTIP = &H400
LVS_EX_UNDERLINEHOT = &H800
LVS_EX_UNDERLINECOLD = &H1000
LVS_EX_MULTIWORKAREAS = &H2000
LVS_EX_LABELTIP = &H4000
LVS_EX_BORDERSELECT = &H8000
LVS_EX_DOUBLEBUFFER = &H10000
LVS_EX_HIDELABELS = &H20000
LVS_EX_SINGLEROW = &H40000
LVS_EX_SNAPTOGRID = &H80000
LVS_EX_SIMPLESELECT = &H100000
End Enum 'LVS_EX

Public Enum LVM
LVM_FIRST = &H1000
LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
End Enum 'LVM


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


Private Function GetVisibleItemsCount(ByRef listView As ListView) As
Integer

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

Return (visibleCount)

End Function




Bartol
 
Dim li As ListViewItem

li = ListView1.Items(Convert.ToInt32(textbox1.text))

Debug.WriteLine(li.Bounds.ToString)
Debug.WriteLine(ListView1.ClientRectangle)

If (li.Bounds.Y + (li.Bounds.Height / 2)) <
ListView1.ClientRectangle.Height Then
'This is visible
Debug.WriteLine("Yes")
Else
Debug.WriteLine("No")
End If


// If you want the number of visible items, then simply take the hight of
the controls bounds and do a a modulo division using the item hight as the
denominator.



--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
Hi Terry,

Did you see it, Herfried is trying to break the old record in this newsgroup
from Nak and Fergus to get the longest thread.

(Although Herfried was as well involved in that previous with a lot of
messages of course)

(Nothing wrong Herfried, I just have fun about it, feel free to do what you
want)

:-)

Cor
 
What was the subject topic for this thread your talking about ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
Terry,

No Equals on interfaces

However it is just to tickle Herfried a little bit.

And I am sure for myself that he opens every message with OT in this
newsgroup.

:-)

Cor
 
Back
Top