WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: bmclellan on February 22, 2019, 08:57:52 AM

Title: Single Select Only ItemBox
Post by: bmclellan 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
Title: Re: Single Select Only ItemBox
Post by: td 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.
Title: Re: Single Select Only ItemBox
Post by: bmclellan 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
Title: Re: Single Select Only ItemBox
Post by: bmclellan 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
Title: Re: Single Select Only ItemBox
Post by: td 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.
Title: Re: Single Select Only ItemBox
Post by: bmclellan 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