Detecting first row in ListView

Is there a method of detecting which row number is the first row displayed in 
a ListView when the view has been scrolled down?  There doesn't seem to be an 
event that is fired when the user scrolls the list up or down.  Is there 
another method of detecting the top row number in the view?

Thanks,
Charlie
0
Utf
6/1/2010 2:10:01 PM
vb.general.discussion 1016 articles. 0 followers. Follow

7 Replies
1148 Views

Similar Articles

[PageSpeed] 28

=?Utf-8?B?Q2hhcmxpZQ==?= <Charlie@discussions.microsoft.com>
wrote in
news:843217DD-4384-4250-853C-4A96C5D004D7@microsoft.com: 

> Is there a method of detecting which row number is the
> first row displayed in a ListView when the view has been
> scrolled down?  There doesn't seem to be an event that is
> fired when the user scrolls the list up or down.  Is there 
> another method of detecting the top row number in the view?
> 
> Thanks,
> Charlie
> 

Blindly assuming VB6 and v6 of CommControls.......

Dim lvi as ListItem

set lvi = Listview1.GetFirstVisible()

If Not lvi is Nothing then

    	'lvi is set to the first visible item

End If
0
DanS
6/1/2010 2:22:25 PM
That worked, thanks.  Now if I can just figure out how to tell if the list is 
being scrolled... I'm pasting a combobox in one column, on the selected row, 
much like Excel's Data Validation feature.  It worked great until I scrolled 
the list -- hmm, the combo didn't move with the row.  :(

If there's no easy way to detect if the list is being scrolled I'll just 
forget the whole feature and put the combo below the listview.

Thanks

"DanS" wrote:

> =?Utf-8?B?Q2hhcmxpZQ==?= <Charlie@discussions.microsoft.com>
> wrote in
> news:843217DD-4384-4250-853C-4A96C5D004D7@microsoft.com: 
> 
> > Is there a method of detecting which row number is the
> > first row displayed in a ListView when the view has been
> > scrolled down?  There doesn't seem to be an event that is
> > fired when the user scrolls the list up or down.  Is there 
> > another method of detecting the top row number in the view?
> > 
> > Thanks,
> > Charlie
> > 
> 
> Blindly assuming VB6 and v6 of CommControls.......
> 
> Dim lvi as ListItem
> 
> set lvi = Listview1.GetFirstVisible()
> 
> If Not lvi is Nothing then
> 
>     	'lvi is set to the first visible item
> 
> End If
> .
> 
0
Utf
6/1/2010 5:54:02 PM
Or the API method :-)


Private Const LVM_FIRST As Long = &H1000
Private Const LVM_GETTOPINDEX As Long = (LVM_FIRST + 39)
Private Const LVM_GETITEMCOUNT As Long = (LVM_FIRST + 4)

Private Declare Function SendMessage Lib "user32.dll" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByRef lParam As Any) As Long


Private Function GetTopItem(LV As ListView) As Long
If SendMessage(LV.hwnd, LVM_GETITEMCOUNT, 0, 0) > 0 Then
GetTopItem = SendMessage(LV.hwnd, LVM_GETTOPINDEX, 0, 0) + 1
End If
End Function

Ivar
(Yep I still read every so often:) 
0
Ivar
6/1/2010 6:01:14 PM
=?Utf-8?B?Q2hhcmxpZQ==?= <Charlie@discussions.microsoft.com>
wrote in
news:F0DE2342-631C-4F46-B3F0-8E8DF328AC60@microsoft.com: 

> That worked, thanks.  Now if I can just figure out how to
> tell if the list is being scrolled... I'm pasting a
> combobox in one column, on the selected row, much like
> Excel's Data Validation feature.  It worked great until I
> scrolled the list -- hmm, the combo didn't move with the
> row.  :( 
> 
> If there's no easy way to detect if the list is being
> scrolled I'll just forget the whole feature and put the
> combo below the listview.

Easy is subjective to your skill level.

I'm looking back at a project I worked on that had a multi-
column listview in it that was a d/l que. One of the sub-items 
was a progress bar that is actually a pbar control that I 
placed 'in' the listview using the SetParent API call, and 
then I subclassed the listview for notifications sent to it by 
its scroll bar.........the parent of the scroll bar is the 
listview, whenever the scroll bar scrolls, it sends a 
notification message to its parent (the listview) that a 
scroll event happened.


The buzz word here.....subclass. There are several subclassing 
controls around the internet that make it easier to do if need 
be.

Once the subclass is set up, this is the call in it's 
WindowProc.....


If iMsg = WM_VSCROLL Or iMsg = WM_HSCROLL Or iMsg = 
WM_MOUSEWHEEL Then
    	CallYourSubToRepositionTheControl
End If

To me, fairly easy. It depends on your skill level.












 
> 
> Thanks
> 
> "DanS" wrote:
> 
>> =?Utf-8?B?Q2hhcmxpZQ==?=
>> <Charlie@discussions.microsoft.com> wrote in
>> news:843217DD-4384-4250-853C-4A96C5D004D7@microsoft.com: 
>> 
>> > Is there a method of detecting which row number is the
>> > first row displayed in a ListView when the view has been
>> > scrolled down?  There doesn't seem to be an event that
>> > is fired when the user scrolls the list up or down.  Is
>> > there another method of detecting the top row number in
>> > the view? 
>> > 
>> > Thanks,
>> > Charlie
>> > 
>> 
>> Blindly assuming VB6 and v6 of CommControls.......
>> 
>> Dim lvi as ListItem
>> 
>> set lvi = Listview1.GetFirstVisible()
>> 
>> If Not lvi is Nothing then
>> 
>>          'lvi is set to the first visible item
>> 
>> End If
>> .
>> 

0
DanS
6/2/2010 12:02:09 AM
"... It depends on your skill level" -- or on the magic formula:

  Success = Sqr(MyLaziness) / TimeAllottedFor(Project) * UserApathy

I figured there was an API or programmable method of accomplishing this, but 
I was hoping for a built-in method or property in the control.  I thought it 
would be cool but don't have the time to make it work.  (That, plus my skill 
level may be lacking.)

The sad part is that whenever I DO accomplish something cool, my users 
seldom even notice or have any idea what really went into making something 
work slick.

:/  sigh

Thanks though.

"DanS" wrote:

> =?Utf-8?B?Q2hhcmxpZQ==?= <Charlie@discussions.microsoft.com>
> wrote in
> news:F0DE2342-631C-4F46-B3F0-8E8DF328AC60@microsoft.com: 
> 
> > That worked, thanks.  Now if I can just figure out how to
> > tell if the list is being scrolled... I'm pasting a
> > combobox in one column, on the selected row, much like
> > Excel's Data Validation feature.  It worked great until I
> > scrolled the list -- hmm, the combo didn't move with the
> > row.  :( 
> > 
> > If there's no easy way to detect if the list is being
> > scrolled I'll just forget the whole feature and put the
> > combo below the listview.
> 
> Easy is subjective to your skill level.
> 
> I'm looking back at a project I worked on that had a multi-
> column listview in it that was a d/l que. One of the sub-items 
> was a progress bar that is actually a pbar control that I 
> placed 'in' the listview using the SetParent API call, and 
> then I subclassed the listview for notifications sent to it by 
> its scroll bar.........the parent of the scroll bar is the 
> listview, whenever the scroll bar scrolls, it sends a 
> notification message to its parent (the listview) that a 
> scroll event happened.
> 
> 
> The buzz word here.....subclass. There are several subclassing 
> controls around the internet that make it easier to do if need 
> be.
> 
> Once the subclass is set up, this is the call in it's 
> WindowProc.....
> 
> 
> If iMsg = WM_VSCROLL Or iMsg = WM_HSCROLL Or iMsg = 
> WM_MOUSEWHEEL Then
>     	CallYourSubToRepositionTheControl
> End If
> 
> To me, fairly easy. It depends on your skill level.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  
> > 
> > Thanks
> > 
> > "DanS" wrote:
> > 
> >> =?Utf-8?B?Q2hhcmxpZQ==?=
> >> <Charlie@discussions.microsoft.com> wrote in
> >> news:843217DD-4384-4250-853C-4A96C5D004D7@microsoft.com: 
> >> 
> >> > Is there a method of detecting which row number is the
> >> > first row displayed in a ListView when the view has been
> >> > scrolled down?  There doesn't seem to be an event that
> >> > is fired when the user scrolls the list up or down.  Is
> >> > there another method of detecting the top row number in
> >> > the view? 
> >> > 
> >> > Thanks,
> >> > Charlie
> >> > 
> >> 
> >> Blindly assuming VB6 and v6 of CommControls.......
> >> 
> >> Dim lvi as ListItem
> >> 
> >> set lvi = Listview1.GetFirstVisible()
> >> 
> >> If Not lvi is Nothing then
> >> 
> >>          'lvi is set to the first visible item
> >> 
> >> End If
> >> .
> >> 
> 
> .
> 
0
Utf
6/2/2010 3:49:01 PM
On 02/06/2010 16:49, Charlie wrote:
> The sad part is that whenever I DO accomplish something cool, my users
> seldom even notice or have any idea what really went into making something
> work slick.

Yeah, they only notice stuff when it breaks or they explicitly request it.

But it works the other way, you can fix/adjust things and people don;t 
notice :)

-- 
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
0
Dee
6/3/2010 12:50:12 PM
....and the explicit stuff they want (for moderate change) "this afternoon?", 
or (for major rewrite) "by the end of the month?"

Then when I put in unpaid overtime to get something done pronto, the .exe 
sits there on the shelf for weeks!  The day I release the next phase I get 
squawks about the previous release that could've been incorporated into the 
new release along the way!

To think I could've been an airline pilot instead: set the autopilot and 
flirt with the flight attendants, or snooze (Northwest).

LOL

"Dee Earley" wrote:

> On 02/06/2010 16:49, Charlie wrote:
> > The sad part is that whenever I DO accomplish something cool, my users
> > seldom even notice or have any idea what really went into making something
> > work slick.
> 
> Yeah, they only notice stuff when it breaks or they explicitly request it.
> 
> But it works the other way, you can fix/adjust things and people don;t 
> notice :)
> 
> -- 
> Dee Earley (dee.earley@icode.co.uk)
> i-Catcher Development Team
> 
> iCode Systems
> 
> (Replies direct to my email address will be ignored.
> Please reply to the group.)
> .
> 
0
Utf
6/3/2010 3:07:08 PM
Reply:

Similar Artilces:

MultiWorkbook Change Event Detection / Spell Checker
Excel 2003 or 2007. Looking to be able to force spell checking whenever any cell content is is changed. I've been successful on a single workbooks by adding Spell Check execution on Worksheet_Change. I'm hoping to take this one step further - make it an 'Add-In' so the check will run for any workbook. It looks like the Worksheet_Change event only triggers for the host workbook so an 'Add-in' will not do the job. Any suggestions to force spell checking on a change for any workbook/worksheet I modifiy? TIA, - Pat The way I would go about this i...

Select alternate rows to copy
I would like to select alternate rows within a range on a worksheet to copy to another sheet. Any ideas on how to do this? -- Christina Christina Use a spare column (I used B but any will do), enter this formula and copy down to the full extent of your data. You will get alternating TRUE, FALSE =MOD(ROW(A2),2)=0 Now invoke an autofilter (Data>Filter>Autofilter) and filter on which one you want. Copy that data and pate to another sheet. -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS "Christina" <Christina@disc...

How to detect changes in a column?
If I have a table with sales forecast data (columns) like Customer, Amount and Status, what would be the best way to track changes in this table so I can compare my forecast week after week? -- inomata ------------------------------------------------------------------------ inomata's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=18938 View this thread: http://www.excelforum.com/showthread.php?threadid=493571 ...

Is there a way to "lock" columns, rows and borders so new data ca.
Help! I don't want to have reformat each time. I have several pages that should look exactly the same, and I want to just fill in the blanks once the format is set up. Is there a way to lock the formats? Hi have a look at 'Tools - Protection -- Regards Frank Kabel Frankfurt, Germany "glaserk" <glaserk@discussions.microsoft.com> schrieb im Newsbeitrag news:C00B00BF-327B-48E1-8F66-67057C8B66C3@microsoft.com... > Help! I don't want to have reformat each time. I have several pages that > should look exactly the same, and I want to just fill in the blanks...

Populate 2nd Form w/Data from First
I have two forms: frmDtaEntryMain and frmDtaEntrySE. FrmDataEntryMain has underlying table: tblDta. FrmDtaEntrySE has underlying table: tblSE There is a common field in both forms: ProjectID, which is a text field. When in frmDtaEntry, I have a button to open frmDtaEntrySE. If a record with the same ProjectID exists in tblSE, I would like that record displayed when frmDtaEntrySE opens. If a record currently does not exist in tblSE with the same ProjectID, I would like to populate the ProjectID field in frmDtaEntrySE with the value from the ProjectID field in frmDtaEntryMain Th...

detect and repair
my outlook 2002 had some hyperlink problems which were corrected when i used the 'detect and repair' option in help. now i have lost my addresses and all the e-mail that was in my inbox. How do i recover these items? Check this page for all you need to know: http://www.slipstick.com/config/backup.htm -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP http://home.hawaii.rr.com/schorr **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup. Mahalo! "Mark Conner" <mdconner@prodigy.net> wrote ...

Duplicate detection detecting inactive records?
Is there any way to configure duplicate detection to not look at inactive records? I can't find any way to set this on the rules. Thank you! ...

Deleting empty rows
My spreadsheet looks like this: A B C D E 1 data data 2 3 4 data data 5 data 6 data 7 data 8 data 9 data 10 data 11 data 12 13 14 data data 15 16 17 data data 18 data 19 data 20 data 21 data 22 ...

How to Detect and prevent CD burn
HI, How can i stop to CD burn of any file from my system to CD.How to detect the event of CD burn and how can i stop CD burn.Basically i want to secure my file from CD burn. plz reply soon. regds vinay sheel vinays@aditi.com Vinay wrote: > HI, > How can i stop to CD burn of any file from my system to CD.How to detect the > event of CD burn and how can i stop CD burn.Basically i want to secure my > file from CD burn. You can restrict access to a file only to a certain users through NT/win200 access privileges. You can encrypt a file and therefore restrict access to a file on...

Parameter query for a combo box row source
A query for a combo box on a form uses a value from a text box on the same form. Can I refer to the text box without specifying the form name? e.g. Currently I am using "Forms!Form1!Text1" - would like to use something like "Forms!(Me.Name)!Text1" No. If you use the criteria in the form, it must include the form name to find the text box. It might be possible to write a VBA function that returns the value of the active text box on the active form, and then use the function in the criteria of your query. Alternatively, it might be better to avoid putting the crit...

Insert row with formatting from row below instead of row above?
My default Excel template has the top row formatted as a header, with bold text and a dark bottom border to distinguish it from the rows below. So if I insert a row at row 2, the new row is formatted like the header. Then I have to select the new row and remove the bold font, remove the dark border, select the header row and reapply the bottom border. Is there a way I can change the insert default so that it takes it's formatting from the row below instead of the row above. Or better yet, so that it has no formatting at all? Hi AFAIK you can't change this behaviour -- Regards Fra...

My Computer not detecting my external harddrive
I have a IDE hard drive with USB casing and connected to my USB port. The problem is the hard drive partitions are not shown up in My computer. But My Computer->Manage->Storage->Disk management shows the hard drive with 3 partitions and all the three are healthy.I know there are a few bad sectors. I am sure I have not made any changes in registry that prevents drives from being shown. Please help me. Do the partitions have drive letters assigned? karthikaravind wrote: > I have a IDE hard drive with USB casing and connected to my USB port. > The problem is the ha...

Hiding blank rows
I have a spreadsheet with columns, first name, last name, home phone, business phone and cell phone. When I don't have phone information in any of the three columns I would like that column to be hidden or deleted. Can I do this in some automated fashion? Thanks. Michael try adding a column in that column put something like =if(counta(b2-d2)>0,"",1) and use autofilter to hide the 1s "mlkpied" wrote: > I have a spreadsheet with columns, first name, last name, home phone, > business phone and cell phone. When I don't have phone information in any of ...

extracting multiple rows of data from another worksheet
I have one worksheet, full of data. In another worksheet, I would like to search through the data individuals who belong to a certain group and then extract the entire row of information for that particular individual into a new worksheet. How can I achieve this using formulas? EggHeadCafe - Software Developer Portal of Choice Silverlight Modal Dialog With Custom User Controls http://www.eggheadcafe.com/tutorials/aspnet/a01af6c8-c067-4fdd-bc01-d47cf3410feb/silverlight-modal-dialog.aspx Try something like this adapted to your data, column and rows. This will return 12 columns of da...

GUID is not detected by server .& cannot go offline...SFO.
why is the server not detecting the GUID attached to the subject line of email...what could be the problem... Also i am not able to go offline ..I get an error Domain canot be contacted or does not exist... Any sugestions... Thanks a million. ...

Mic not detected
I upgraded from Vista to W7 when it first came out. I have just recently realized that it apparently cut off the mic and I cannot record anything. I can still hear cd's.etc. I did not discover this until I tried to send a video message to my son who just got deployed to Iraq. Dell customer support has been useless thus far. Thanks for any suggestions as to how to fix this problem. On May 17, 11:51=A0am, "andy jones" <jandy78...@aol.com> wrote: > I upgraded from Vista to W7 when it first came out. I have just recently > realized that it apparently cut...

Last Name First Name Fiddled and Fiddled and still stumped
It is giving me a migraine. Trying to transfer over contacts from Outlook into a Nokia 6230. They always come as First Name Last Name, when I need them to come Last Name First Name. I am guessing it is a problem with Outlook, but they displayed as Last Name First Name in Outlook. I have fiddled and fiddled with Outlook, gone through all the various helps, and now through myself on your mercy. Any spelling mistakes due to eyes glazing over and loss of will to live. I am going for a syndol. If the names are not appearing correctly in the Nokia, how is this an Outlook problem? You should be ask...

Need to stay on first sheet
I have an inventory database. I have two tables. One for people, TblPeople. One for invoices, TblInvoice. TblInvoice has invoice as a primary key (autonumber) I have a query that will create a new invoice number whenever I input a new customer number. Great. My problem. On the form, whenever I create a new number, it creates a new blank sheet (2 of 2). How do set it to not create a second blank sheet and stay on the first sheet with my new number (1 of 1)? EB On Sat, 14 Apr 2007 19:27:44 +0100, "e b" <me@yahoo.com> wrote: >I have an inventory database. I have...

detecting which control has focus
I have an application that I am writing and I need to be able to detect which control has focus (I am using edit controls). I figured out how to set the focus by creating a member control variable and using the setfocus() function, but how do detect which control has focus? There is a getfocus() in the control member variable, but I have been unsuccessful in using it? I am using the PreTranslateMessage(MSG* pMsg) function to detect when the Return key is pressed and then I automatically go the the next edit control, but I want to do different code depending on which Edit control has focus a...

Cannot detect previous login you need to run frontstep crm at least once
We have a user who was on extended leave for a few months and now when ever he opens up outlook 2000 sr-1 on his computer (Windows 98se) he gets a message that "Cannot detect previous login you need to run frontstep crm at least once. Front step outlook extension will be disabled for current outlook session." When I say OK you get another message that "The add-in "psExcExt.dll" could not be installed or loaded. This problem may be resolved by useing detect and repair in the help menu. Unable to load "psExcExt.dll" you may be out of memory or out ...

How do I set up a 2nd Outlook account separate from the first?
I currently use Outlook with my handheld device. Another member of our family would also like to use Outlook with their own information. What is the best way to do this? Thanks! We don't know since you have not posted your version of Outlook. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted without reading. After furious head scratching, genie asked: | I currently use Outlook with my handheld device. Another member of | our family would also like to use Outlook with th...

Linking a column with a row
I'm trying to set up Excel to link several rows with several columns. I guess I could do it manually with the "=" function for everyone, but that'd take a long time and a chance of a mistake is fairly high. What I have is 2 sheets, On sheet two, I have a chemical that is broken down into 8 pieces of data going from H3 to H10, I then have a space and then repeat for a another chemical with 8 pieces of data from H12 to H19 and I repeat for several hundred. On sheet one, I need to have those 8 pieces show up in a row, so H3 from sheet two shows up in N9, H4 shows up ...

using row()
so I can use =exact(a1, "x") but is there a way to simply return the 1st row to this? along the lines of =exact((row1), "x) it would help as a1 is static, and (row1) would be dynamic.... again much thanks, jare -- jared ----------------------------------------------------------------------- jaredh's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1553 View this thread: http://www.excelforum.com/showthread.php?threadid=27127 this??? =EXACT(INDIRECT("b"&ROWS(1)+9),"x") -- Don Guillett SalesAid Software donaldb@281.com ...

Align Column Data to match row locations
Hello, I have a problem that needs to be solved in Excel. I have two column of data, and need to align the information in one column(B), with th information in another(A). For example: Column A Col B CODE1 CODE4 CODE2 CODE27 CODE3 CODE45 CODE4 onto CODE45 This does not work with a simple data sort since there are space between the values in Column B that need to be aligned with the correc row in Column A. Currently the company manually copies and then paste the correct value in Column B to the correct position in Column B tha is aligned with its match in Column A. Cheers and thanks for t...

Shading rows
Hello - I am a teacher in an alternative school where we must keep up with the contact hours of each student. I have been doing this with Excel for 2 years but there is one thing that really bugs me. I shade every other row light gray to make the easier to follow a given student across an entire month. This works fine until I have to add a new student (I keep them in alpha order). I can't copy, cut and paste because that screws the shadings up so I have to insert a row, etc. etc... Bottom line - can I lock the shadings of a row so I can copy and paster data only? Thank you ...