Hello. I have three ListBoxes (boxMain, boxA, boxB) on a Form: Item 1 on boxMain matches with Item 1 on boxA and Item 1 on boxB and so on. Multiple items can be selected in all ListBoxes.
Here's what I want to implement, with the help of an example:
(1)If User scrolls to Item 10 in boxMain, Items 10 in boxA and boxB also come into view. This, I've been able to achieve by having a scroll event. It doesn't work if I scroll via the scroll-bar at a slow pace. But otherwise it works well. Can this be improved? How can it be improved?
(2)If User selects Item 10 in boxMain, Items 10 in boxA and boxB gets selected as well. But the User can then decide to de-select Item 10 in one or both of the ListBoxes boxA, boxB; de-selecting both deselects Item 10 in boxMain.
Okay, it's rather complicated. But what I am really stuck at is this:
(1)How can the last selected-index or last de-selected-index be obtained from a ListBox? For example, if the selected indices are [0, 3, 7, 9] and I select Item 5, how can I obtain "5"? And if I de-select Item 3, how can I obtain "3"?
(2)Am I even using the right control for this? Would I be better off with a Tree-View?
Thanks!
ABPosted Mar 8, 2006, 11:24 AM
Thanks for the response, Pasha. I'll certainly try out your suggestion.
The ListBox problem did become a big mess and I decided to use TreeView. It seems to be working well.
Thanks.
Pasha WilsonPosted Mar 8, 2006, 8:59 AM
A listbox is gonna make your life very difficult. I would use a ListView and change the View property to list. This will make it simulate a ListBox, the main difference being that the items in the collection have a Tag property which can store pretty much anything you like. In your case an identifier for the items in the list. This way when the user selects one item in the main list, you can identify which one was clicked using the Tag property and find the items in the other lists relatively easily.
Hope this helps.
P.