-
Hi there,
I have a ListBox with > 100 items, at the same time I have a Frame which has multible CheckBoxes. The Q is:
How can I make the frame move up/down with whichever is selected from the listbox ??
I have this code:
Code:
Private Sub Form_Load()
Frame1.Left = List1.Left + List1.Width
Frame1.Top = List1.Top - 180
End sub
Private Sub List1_Click()
Frame1.Top = List1.ListIndex * 300
End Sub
The 2 problems i'm having are:
- The Listindex When it's (0) ??
- When selecting item > 20 , the Frame would be Hidden !?
Thanx for any help.
-
Am I not clear enough !?
If so, please let me know?
Thanx.
-
Unfortnately, yeah, it's a bit hard to picture what you're trying to do.
Do you want scroll the contents of the frame?
You could also make the ckeckboxes in the listbox.
-
To move only the CheckBoxes, you could set their Tag property to "1" then use a For Each loop to move them.
Code:
Dim MyObj As Object
For Each MyObj In Form1.Controls
If MyObj.Tag = "1" Then
MyObj.Move MyObj.Left + 50
End If
Next MyObj
-
Thanx for replying.
Yes. I want to move/scroll the whole frame with it's contents. :)
The ListBox would have Only 20 items visible. When you click item # 3 I want that frame to (move) to be in the same level with the clicked item.
The problem is: If, for example, I click item # 41 , the frame would move way below.
Because, as you can see from the code, it takes the ListIndex * 300
Again, Thanx.
-
Well you could move the content as Meg showed but instead of using the tag property use Getparent api and compare it to the frame hwnd. But i would use a regular listbox, also if you have 300 checkboxes, you won't have much resources and RAM let when you run it.
-
OK, Ok. Let me put it this way.
How can I find the (X,Y) of the selected item in the List1_Click Event ??
Which could be found in List1_MouseDown Event.
Thanx.
-
You could either store x and y from mousedown event since it will fire before click, or use getcursorpos and clienttoscreen api to get the position in pixels