Single Select Only ItemBox

Started by bmclellan, February 22, 2019, 08:57:52 AM

Previous topic - Next topic

bmclellan

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

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

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

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

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

Thanks Tony, I'll have to check that out. I've never tried that control before.


Barry