|
-
May 11th, 2005, 09:47 AM
#1
Thread Starter
New Member
[RESOLEVD] Listview & Scrolling troubles
Hi,
I'm using a listview control to have a log screen. So every 10 seconds a new line is added, at the bottom.
Now, I know how to code that the last line added to the listview is always visible by using the ensurevisible property.
-----------------------------------------------------------------------------
Public Sub AddToLstv(ByVal lstvListView As ListView, ByVal AddItem As String, ByVal ImageNumber As Integer)
lstvListView.Items.Add(AddItem, ImageNumber)
lstvListView.EnsureVisible(lstvListView.Count - 1)
End Sub
-----------------------------------------------------------------------------
But when I try to read my log window, it is ennoying that the listview jumps down everytime a new line is added. So I always have to search again where I was reading.
So, I would like my listview having another behaviour:
- When the scrollbar is in the down position, I see every new line added & the listview scrolls automatically up.
- But when I put the scrollbar up, the listview keeps adding new lines, but doesn't jump everytime to that new line, and stays simple on the place I'm reading.
The same kind behaviour like in a chat-channel on irc, or when using a ftp-client, etc...
Anybody can help, or suggest a solution?
Thx,
djrud
Last edited by djrud; Jun 15th, 2005 at 07:15 AM.
Reason: Resolved
-
May 11th, 2005, 10:39 AM
#2
Re: Listview & Scrolling troubles
Hi djrud,
I did a little mock up using a listview and a button. It seemed to do what you are looking for
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static i As Integer
i += 1
lstvListView.Items.Add(i.ToString, i)
'use the item Rectangle and the listviews' height property
'to determine how many on the list are visible
Dim r As Rectangle = lstvListView.GetItemRect(0)
Dim nVisibleItems As Integer = lstvListView.Height \ r.Height
'then use the topitem proerty with the number of visible items
'to know if the new item should be visible
If lstvListView.TopItem.Index + nVisibleItems >= lstvListView.Items.Count - 1 Then
lstvListView.EnsureVisible(lstvListView.Items.Count - 1)
End If
End Sub
GL
kevin
Last edited by kebo; May 11th, 2005 at 11:11 AM.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
May 12th, 2005, 03:24 PM
#3
Thread Starter
New Member
Re: Listview & Scrolling troubles
Thx Kebo, works fine!
Greetz,
djrud
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|