473,796 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listview Visible Row Count


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!
Nov 20 '05 #1
10 8240
try listview.items. count
tony

"Henry" <an*******@devd ex.com> wrote in message
news:uI******** ********@TK2MSF TNGP11.phx.gbl. ..

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!

Nov 20 '05 #2
* "t perkins" <tp******@roger sandhollands.co m> scripsit:
try listview.items. count


This will return the total number of items.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

I was aware of the listview "item count" propery to obtain the total
number of items.

However, what I need to figure out is how may rows in the listview
display area are advanced or vice versa when the user presses the "page
down" or the "page up " keys. I will take the number and then
increment/decrement my record position/counter that I display for the
user.

Any other ideas?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4
You could probably use the Control.ClientS ize Property in conjunction with
the protected property Control.FontHei ght and do some fun mathmatics there
(not really diffucult.

RowsVisible = Control.ClientS ize.Height / Control.FontHei ght

I would round it and you should have a good idea of how much space is being
used... I think you can get the height of the columns as well for good
measure...
"Henry" <an*******@devd ex.com> wrote in message
news:uI******** ********@TK2MSF TNGP11.phx.gbl. ..

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!

Nov 20 '05 #5
Also noted.. You can use Control.CreateG raphics method and use embedded
methods in that such as MEasureString I suppose...

And add padding as neede.d

-CJ
"CJ Taylor" <no****@blowgoa ts.com> wrote in message
news:10******** *****@corp.supe rnews.com...
You could probably use the Control.ClientS ize Property in conjunction with
the protected property Control.FontHei ght and do some fun mathmatics there
(not really diffucult.

RowsVisible = Control.ClientS ize.Height / Control.FontHei ght

I would round it and you should have a good idea of how much space is being used... I think you can get the height of the columns as well for good
measure...
"Henry" <an*******@devd ex.com> wrote in message
news:uI******** ********@TK2MSF TNGP11.phx.gbl. ..

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!


Nov 20 '05 #6
Tks for the suggestion. I'll work the idea and see what I can come up
with.

In the mean time any other suggestions would also be welcomed.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7
For anyone who is interested below is a solution:

Dim lvCount
lvCount = ListView_GetVis ibleCount(ListV iew1.Handle)

Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNTPER PAGE As Long = (LVM_FIRST + 40)
Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA"
(ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long

Private Function ListView_GetVis ibleCount(ByVal hwndlv As IntPtr) As
Long
ListView_GetVis ibleCount = SendMessage(hwn dlv,LVM_GETCOUN TPERPAGE, 0&,
0&)
End Function
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #8
Ahh... Trusty ol' Win32 API....
"Henry" <an*******@devd ex.com> wrote in message
news:Oh******** ********@TK2MSF TNGP09.phx.gbl. ..
For anyone who is interested below is a solution:

Dim lvCount
lvCount = ListView_GetVis ibleCount(ListV iew1.Handle)

Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNTPER PAGE As Long = (LVM_FIRST + 40)
Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA"
(ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long

Private Function ListView_GetVis ibleCount(ByVal hwndlv As IntPtr) As
Long
ListView_GetVis ibleCount = SendMessage(hwn dlv,LVM_GETCOUN TPERPAGE, 0&,
0&)
End Function
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #9
* Henry <an*******@devd ex.com> scripsit:
For anyone who is interested below is a solution:

Dim lvCount
lvCount = ListView_GetVis ibleCount(ListV iew1.Handle)

Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNTPER PAGE As Long = (LVM_FIRST + 40)
Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA"
(ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long

Private Function ListView_GetVis ibleCount(ByVal hwndlv As IntPtr) As
Long
ListView_GetVis ibleCount = SendMessage(hwn dlv,LVM_GETCOUN TPERPAGE, 0&,
0&)
End Function


Replace all 'As Long' with 'As Int32', at least 'hwnd' should be an
'IntPtr'. Remove the '&' suffix from the '0&'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #10

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

Similar topics

8
22325
by: Jon Ripley | last post by:
Using VB6 (for two weeks!) I could get a ListBox search working perfectly but with a ListView it has completely stumped me. I've not found any previous posts that have helped :( The user enters a string into a text box (txtStreet) and as they type any matching entry in the listview (lsvStreets) is highlighted and made visible. The search highlights the first item starting with the text in txtStreet. The listview contains 6,000 rows...
2
3012
by: Aaron Queenan | last post by:
Is there any way to know whether the OnItemCheck is being called in response to a user action (mouse or keyboard) as opposed to the form loading? I have a class which derives from System.Windows.Forms.ListView. Among other features, it enables the checkboxes and overrides the OnItemCheck() method. I have placed this ListView on a form and use form.ShowDialog() to display it whenever the user presses a certain button. If the user...
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
0
1381
by: Giang Pham | last post by:
Dear all, When adding a row in a listview, I want to do some thing like this: 1. Make sure this new item will be all visible 2. Set the last item as selected item 3. Make it as focus and hightlight as it was selected (by left-click to this item on the listview) saple code: m_ctrlRecordList.EnsureVisible(m_ctrlRecordList.Items.Count-1); m_ctrlRecordList.Items.Focused = true; m_ctrlRecordList.Items.Selected = true;
2
2553
by: | last post by:
Hi, Trying to figure out how i can tell if the scrollbar is in the bottom of my listview, im using the listview to display log files and i track them and add new items to the bottom of the listview... the thing is i want the listview to scroll to the last item all the time but only when the scrollbar is in the bottom... Thanks...
7
7220
by: txplayboy2002 | last post by:
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
12
7488
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...
1
8365
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, In my application I need to periodically remove all current items from a ListView and add a new set into it. The following abbreviated code contains the basic idea: private void FillListViewFromFile(string path) {
0
1458
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
9685
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
9535
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
10467
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...
1
10201
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
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...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.