Author Topic: Single Select Only ItemBox  (Read 144 times)

bmclellan

  • Newbie
  • *
  • Posts: 28
Single Select Only ItemBox
« on: February 22, 2019, 08:57:52 am »
Good morning,

I can't seem to figure out how to get the itembox control to only allow for a single selection!

Can anyone point me in the right direction for Dialogs 6.2.


Thanks!
Barry

td

  • Tech Support
  • *****
  • Posts: 2849
    • WinBatch
Re: Single Select Only ItemBox
« Reply #1 on: February 22, 2019, 10:14:03 am »
See IntControl 33 in the Consolidated WIL Help file.  The list box control and multi-select style date back to the early days of WIL Dialogs when dialog templates didn't have style attributes so it still uses the old IntControl method of setting this particular window style.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bmclellan

  • Newbie
  • *
  • Posts: 28
Re: Single Select Only ItemBox
« Reply #2 on: February 22, 2019, 10:38:22 am »
Thanks Tony,

I'm assuming that has to be for the entire dialog box then? I have a few controls that need multi-select and a few that need single.



Barry

bmclellan

  • Newbie
  • *
  • Posts: 28
Re: Single Select Only ItemBox
« Reply #3 on: February 22, 2019, 10:52:57 am »
I'm hoping there is an easy flag for this, but for the short term, I wrote some code to do it if anyone is interested in the manual way.

;Turn on item selected
DialogProcOptions(Handle,@deIbSelect,1)          ; Items Selected

;Check in dialog switch statement
case @deIbSelect
    if DialogControlID == "ibMyList" then
        SelectedList=DialogControlGet(handle,"ibMyList",@dcSelect)
        ItemsSelected=ItemCount(SelectedList,@tab)
        if ItemsSelected > 1 then
            DialogControlSet(handle,"ibMyList",@dcSelect,ItemExtract(ItemsSelected,SelectedList,@TAB))
        end if
    end if

td

  • Tech Support
  • *****
  • Posts: 2849
    • WinBatch
Re: Single Select Only ItemBox
« Reply #4 on: February 22, 2019, 01:55:03 pm »
If you want more flexibility, you could consider using the REPORTVIEW control instead of the ITEMBOX control.  The REPOTRVIEW control has a single select style that can be set in the dialog template.  Unfortunately, the LBS_MULTIPLESEL style cannot be removed once a ITEMBOX control is created so you can't use a DllCall to change that window style.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bmclellan

  • Newbie
  • *
  • Posts: 28
Re: Single Select Only ItemBox
« Reply #5 on: February 22, 2019, 02:22:44 pm »
Thanks Tony, I'll have to check that out. I've never tried that control before.


Barry