locked
Anyone know of a dual listbox mover type control? RRS feed

  • Question

  • Hi all,

    I need a 2-listbox mover/selection type control such as the example here:
    http://www.codeguru.com/cpp/controls/listbox/article.php/c4755__1

    For over a week now I've searched countless forums and done myriads of googles.  All I've been able to find is C++ or ASP based stuff.  I really would like this to be VB.net, but at this point, I'd even settle for C# (Thank God for those C# to VB code converters!). 

    I've taken a shot at developing it myself, but am too new to the .Net world to really get anywhere with it other than being completely overwhelmed and frustrated.  I've even looked at some 3rd party custom control webistes, and am even willing to spend a few bucks for this thing, if I could find one that suits my needs.

    All the control needs to do is the equivalent of allowing a user to specify items for a category... basically 3 controls on the form:
    - 1 dropdown to allow the user to pick which category to edit/view
    - 1 listbox to show items which currently belong to the selected category
    - 1 listbox to show all items available - cannot show the items that currently belong to the category selected in the drop down

    Then there should be 4 buttons:
    - Add (move 1 item from the available listbox to the selected listbox)
    - Add All (move ALL items from the available listbox to the selected listbox)
    - Remove (move 1 item from the selected listbox to the available listbox)
    - Remove All (move ALL items from the selected listbox to the available listbox)

    I've thought about trying to implement this using a single checked-listbox, but with the potential for hundreds of items that could be selected for a category, it'd be far too easy for the user to miss a check, and the 2 listbox scenario would be much more user friendly.  Those checked-listboxes work great when there's only a few items to deal with, such as Windows- User-Group management controls.

    It'd be nice if items in the listboxes could be double-clicked or drag-dropped to move between listboxes, but right now I'd settle on just the buttons handling everything.

    The real tricky part for me is the data aspect.  All the data is stored in a SQL db, with a typical scenario of 1 table for the categories, 1 table for all items, then a "link" or many-to-many table indicating which items belong to which categories.  Thus, the selected items listbox needs to be populated with the items belonging to the selected category (simple enough), while the available items listbox needs to be populated, not with all items from the items table, but all items that do not currently belong to the category (very un-simple).  Then there's the whole aspect of saving changes - if a user adds 3 available items to a category then presses save, 3 records/rows would have to be inserted to the many-to-many table.  Even more convoluting for me is if a user removes 3 items then adds 2 different items, then clicks save, the save method has to do 3 deletes and 2 inserts.  (For the data access functionality, I'm using datsets and tableadapters in my app.)

    So, does anyone know of any VB controls like this, be it a 3rd party commercial product, a sample, turtorial, walkthrough, whatever?

    In advance, all replies, advice and suggestions are extremely appreciated!!!

    Thanks,
    Dan

    Friday, October 30, 2009 2:33 PM

Answers

All replies

  • For over a week now I've searched countless forums and done myriads of googles.  All I've been able to find is C++ or ASP based stuff.  I really would like this to be VB.net, but at this point, I'd even settle for C# (Thank God for those C# to VB code converters!).

    if you have seen it in CSharp, use this web site to convert it tinto Visual basic.Net:

    just clcik here http://www.developerfusion.com/tools/convert/csharp-to-vb/#at



    Don't judge me, just Upgrade me. Thanks!
    Friday, October 30, 2009 2:42 PM
  • Thanks for the reply, but I have NOT seen it in C#, only C++ & ASP.
    Friday, October 30, 2009 3:34 PM
  • That is just 2 listboxes that share items. All you need are 2 listboxes and buttons. IF you want the dual listbox as control, then you have to create your own using usercontrol library. Don't bother try to convert the code because you wont get exact conversion to vb.net. That program was C++ and MFC version. Just try to understand what the control does and you can achieve the same things without wasting time searching for vb version.

    kaymaf


    If that what you want, take it. If not, ignored it and no complain
    Friday, October 30, 2009 5:39 PM
  • Dan,

    what you want is not very hard.

    you just need to use the selecteditem and selectedindex of the listboxes.  instead of using buttons i have a project on my website which will show you how to drag and drop items from one listbox to another.  go to the projects page and look for listbox drag and drop.  after that if you have any more questions of need to modify it then post back with the code and what you want to do.
    FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial
    Friday, October 30, 2009 6:01 PM
  • I think you can find your answer in this link:

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2082caa0-5ece-4ad8-8077-8c7170fa6f9f


    I was able to find the above thread in less than 10 seconds by searching this forum.     :)


    Doug

    SEARCH ... then ask
    • Proposed as answer by --Steve-- Saturday, October 31, 2009 4:34 PM
    • Marked as answer by Martin Xie - MSFT Thursday, November 5, 2009 8:24 AM
    Saturday, October 31, 2009 4:14 AM