|
-
Jun 19th, 2008, 11:37 AM
#1
Thread Starter
Addicted Member
[2008] Listboxes, scrollbars question (same value).
Hi guys! I'm trying to find out how to do this:
I got 2 listboxes , when you scroll with the scrollbar
then the other scroll bar of the listbox2 will be at the same value
of listbox1 scrollbar value when it's being moved.
I will try to make it simple:
Listbox1
Listbox2
User moves listbox1 scrollbar, then listbox2 scrollbar will be moved to
the same place.
I can't find a solution for it, so I went to here.
please try to help me.
Thanks!
-
Jun 19th, 2008, 04:46 PM
#2
Re: [2008] Listboxes, scrollbars question (same value).
vb Code:
listbox2.TopIndex = listbox1.TopIndex
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 19th, 2008, 05:04 PM
#3
Re: [2008] Listboxes, scrollbars question (same value).
 Originally Posted by .paul.
vb Code:
listbox2.TopIndex = listbox1.TopIndex
So long as both listboxes contain the same number of items always.
-
Jun 19th, 2008, 05:10 PM
#4
Thread Starter
Addicted Member
Re: [2008] Listboxes, scrollbars question (same value).
thanks, but I want this to happen when the user scrolls
but I can't find something like:
Private Sub ListBox1_ScrollValue change(ByVal Sender...)
I mean where do I put the code so when the scroll is moved , the other will move too?
-
Jun 19th, 2008, 05:25 PM
#5
Re: [2008] Listboxes, scrollbars question (same value).
heres an extended listbox control with a scrolled event
vb Code:
Public Class listboxEx
Inherits ListBox
Private WM_VSCROLL As Integer = &H115
Public Event scrolled()
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_VSCROLL Then
RaiseEvent scrolled()
End If
MyBase.WndProc(m)
End Sub
End Class
heres how to handle it in your form
vb Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim items() As String = {"item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8", "item9", "item10"}
ListboxEx1.Items.AddRange(items)
ListBox2.Items.AddRange(items)
End Sub
Private Sub ListboxEx1_scrolled() Handles ListboxEx1.scrolled
ListBox2.TopIndex = ListboxEx1.TopIndex
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 20th, 2008, 12:42 AM
#6
Thread Starter
Addicted Member
Re: [2008] Listboxes, scrollbars question (same value).
Hi again, well, it sounds complicated more then I excpected.
are you sure there is no easier way?
-
Jun 20th, 2008, 01:21 PM
#7
Re: [2008] Listboxes, scrollbars question (same value).
sorry for the delay.
its quite simple really.
add a new class to your project, call it listboxEx.
then paste the code from the first box above into the class.
run your project, stop it, then at the top of your toolbox you find listboxEx - the extended listbox control - which has a scrolled event you can use
vb Code:
Private Sub ListboxEx1_scrolled() Handles ListboxEx1.scrolled
ListBox2.TopIndex = ListboxEx1.TopIndex
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 20th, 2008, 02:24 PM
#8
Thread Starter
Addicted Member
Re: [2008] Listboxes, scrollbars question (same value).
Thanks ! I will try it when I will be home! Thanks again!
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
|