473,785 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listview - determining nbr of visible rows

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
Nov 21 '05 #1
7 7219
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

<tx***********@ yahoo.com> wrote in message
news:lc******** *************** *********@4ax.c om...
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

Nov 21 '05 #2
There is the EnsureVisible method (this will scroll a listitem into view,
but not tell you if it was visible to begin with).

Greg

<tx***********@ yahoo.com> wrote in message
news:lc******** *************** *********@4ax.c om...
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

Nov 21 '05 #3

<tx***********@ yahoo.com> wrote in message
news:lc******** *************** *********@4ax.c om...
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_GETCOUNTPER PAGE As Integer = LVM_FIRST + 40
Public Const WM_SETREDRAW As Integer = &HB
Public Enum LVS_EX
LVS_EX_GRIDLINE S = &H1
LVS_EX_SUBITEMI MAGES = &H2
LVS_EX_CHECKBOX ES = &H4
LVS_EX_TRACKSEL ECT = &H8
LVS_EX_HEADERDR AGDROP = &H10
LVS_EX_FULLROWS ELECT = &H20
LVS_EX_ONECLICK ACTIVATE = &H40
LVS_EX_TWOCLICK ACTIVATE = &H80
LVS_EX_FLATSB = &H100
LVS_EX_REGIONAL = &H200
LVS_EX_INFOTIP = &H400
LVS_EX_UNDERLIN EHOT = &H800
LVS_EX_UNDERLIN ECOLD = &H1000
LVS_EX_MULTIWOR KAREAS = &H2000
LVS_EX_LABELTIP = &H4000
LVS_EX_BORDERSE LECT = &H8000
LVS_EX_DOUBLEBU FFER = &H10000
LVS_EX_HIDELABE LS = &H20000
LVS_EX_SINGLERO W = &H40000
LVS_EX_SNAPTOGR ID = &H80000
LVS_EX_SIMPLESE LECT = &H100000
End Enum 'LVS_EX

Public Enum LVM
LVM_FIRST = &H1000
LVM_SETEXTENDED LISTVIEWSTYLE = LVM_FIRST + 54
LVM_GETEXTENDED LISTVIEWSTYLE = 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 GetVisibleItems Count(ByRef listView As ListView) As
Integer

Dim visibleCount As Integer = SendMessage(lis tView.Handle,
LVM_GETCOUNTPER PAGE, 0, 0)

Return (visibleCount)

End Function


Bartol
--
Remove "TB" from address to reply
Nov 21 '05 #4
Dim li As ListViewItem

li = ListView1.Items (Convert.ToInt3 2(textbox1.text ))

Debug.WriteLine (li.Bounds.ToSt ring)
Debug.WriteLine (ListView1.Clie ntRectangle)

If (li.Bounds.Y + (li.Bounds.Heig ht / 2)) <
ListView1.Clien tRectangle.Heig ht 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

<tx***********@ yahoo.com> wrote in message
news:lc******** *************** *********@4ax.c om...
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

Nov 21 '05 #5
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
Nov 21 '05 #6
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

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uk******** ******@TK2MSFTN GP14.phx.gbl...
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

Nov 21 '05 #7


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



"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> schreef in
bericht news:et******** ******@TK2MSFTN GP11.phx.gbl...
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

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uk******** ******@TK2MSFTN GP14.phx.gbl...
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


Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6061
by: Daisy | last post by:
I'm writing a NewsReader (seemed like a decent project to start learning with), and want threading like in OE. I've got a treeview and a listview. On Expand/Contract on the listview, I spin through the nodes checking .IsVisible, and those that are visible, I take the info I need (posted name / date) out of the .Tag (is there a better place to put this?), and add them to the listview. For now, it loops from the top, though it might be...
5
4509
by: Phill | last post by:
I've got a Listview control (Detail mode) that I'm adding rows to on another thread from a DB query. The result is about 32,000 rows ans takes a while to finish. I'm adding the rows like this : lv.Items.Add( lvi ); It seems the entire control is redrawing even though usually the new rows being added are not visible. I don't remember this being the case in Win32. Anyway w/ all the flickering going on the LV control is too
2
15275
by: Adam Klobukowski | last post by:
Hello i need to find out the last fully visible item of a Llistview. If it would be a treeview then it would be easy, I'm even thinkin of faking my treeview as listview, but maybe there is some easy way I don't see? -- Semper Fidelis Adam Klobukowski atari@gabo.pl
10
8236
by: Henry | last post by:
Does anyone know how I can determine how many visible rows there are in a vb.net Listview? There is no listview "visible row count" property like there is for a datagrid. Tks in advance for any feedback. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
5
22551
by: Frank Rizzo | last post by:
I reload the items in the listview on a regular schedule (i.e. clear the listview, then load it up with fresh values). I want add a convinience to the user whereby my application remembers the position of the scrollbars after reloading the data. But I can’t figure out how to retrieve the scrollbar position (both horizontal and vertical). Neither can I figure out how to restore the state of the scrollbars. I could theoretically figure...
4
2339
by: John Dann | last post by:
I have a listview control on a simple vb.net form that's populated programmatically. It is set to scrollable and a scroll bar duly appears. However the scroll bar doesn't allow the bottom rows of the list to be seen. For example, if I have 31 rows in the list with the control set to a height that shows maybe 20 rows then the scroll bar allows me to get down to eg row 28 as the bottom row, but not row 31. Yet if I drag the bottom of the...
12
7487
by: J L | last post by:
When I fill a listview, I resize the columns to fit the data. I need to know if the data will fit vertically or if there will be a vertical scroll bar. I need to know this so I can allow for it on the overall size of the listview. My question therefore is, how can I tell if the items I have added will fit in the listview at its given height? A secondary one, just for interest sake...is there a way to determine the exact heght needed...
5
2689
by: Nathan Sokalski | last post by:
I have a DataList that I was having trouble getting the events for. After a bit of help, I realized that I needed to put the databinding inside an If Not IsPostBack() condition. Although this fixed the individual problem, it caused problems in other areas. This is because the DataSource that I use for my databinding changes and must be "rebound". Because there is only one situation where I need the If Not IsPostBack() condition, I think it...
0
1456
by: lsharva | last post by:
Actually, i m working on Windows Application where i have to use the ComboBox and listview in a way , as first we will click the comboBox and then as you click , ListView appear and when we select something , that will be selected at comboBox also and ListView will disappear, and comboBox item should get selected. Here i m having a problem as comboBox gets empty when list View will apear Focus and thatswhy selection become Error, So...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.