MapInfo Pro Developers User Group

 View Only
  • 1.  Pre selecting items in a multi-list box

    Posted 02-07-2018 22:21

    Hi,

    After all this time I now have a requirement to pre-select items in a multi-list box - i.e set the initial selected items. I thought I could just loop though the number of items and set the value so if I had three items then I would do:-

    for n = 1 to 3

        Alter control X value n

    next

    This does not work - it is just the last item that is selected.

    Does anyone know how to do this?

    Many thanks



  • 2.  RE: Pre selecting items in a multi-list box

    Posted 02-09-2018 11:07

    Martin,

    We do a similar thing and it seems to work ok.

    The dialog handler calls a procedure that loops though an array of items pre selected and sets the value as you have done.

    David

     

     

     



  • 3.  RE: Pre selecting items in a multi-list box

    Posted 02-11-2018 16:17

    Hi Martin,

    I am uncertain how to do this officially, but typically I'd use the LB_SETSEL win32 message if you're using a list box: https://msdn.microsoft.com/en-gb/library/ms909693.aspx . If you're using a list view I'd use the LVM_SETITEMSTATE  message instead: https://msdn.microsoft.com/en-us/library/ms930194.aspx



  • 4.  RE: Pre selecting items in a multi-list box

    Posted 02-12-2018 04:01

    Thanks for the replies - I will have another go!?



  • 5.  RE: Pre selecting items in a multi-list box

    Employee
    Posted 02-15-2018 06:13

    Let us know how you get along, Martin.

    The trick is to do the preselecting in the handler of the dialog.

    You can find a sample of how to do this here: http://www.twiav.nl/php/mbsampleM.php#mlbx



  • 6.  RE: Pre selecting items in a multi-list box

    Posted 02-15-2018 06:25

    Hi everyone - sorry I meant to update this. I did get it working and I was on the right path initially. My schoolboy error.. this was done as a part of a dialog rebuild and I had it set as a listbox!

     

    oops 😳 ?