coda
Junior Member
Posts: 74
|
Post by coda on Mar 31, 2022 13:53:14 GMT -5
Hi, I am probably wrong but I swear that years ago I remember reading in the LB help file that there was a native LB way to place line dividers between combobox items... Or am I thinking of listbox items or menu items?? I can't seem to find this so I assume I am wrong and that it would require API calls... mind you, there are a lot of things I struggle to find now that help is in html format. Does anyone know how to achieve this? Any help greatly appreciated.
|
|
|
Post by Carl Gundel on Mar 31, 2022 14:19:50 GMT -5
Hi, I am probably wrong but I swear that years ago I remember reading in the LB help file that there was a native LB way to place line dividers between combobox items... Or am I thinking of listbox items or menu items?? I can't seem to find this so I assume I am wrong and that it would require API calls... mind you, there are a lot of things I struggle to find now that help is in html format. Does anyone know how to achieve this? Any help greatly appreciated. I don't believe that there is any way to do this unless you create some sort of custom control using APIs or a DLL.
|
|
|
Post by Walt Decker on Mar 31, 2022 15:18:10 GMT -5
Your best bet is to use a listview control. There is one available in the "API and DLL" thread.
Next best is to set your listbox or combobox text to a fixed font then pad your array text fields.
|
|
|
Post by tsh73 on Mar 31, 2022 15:48:50 GMT -5
It was about menu items indeed From the Help file:
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Mar 31, 2022 22:51:55 GMT -5
Thanks for your reply, Carl. :-) Indeed, you are right, tsh73. It WAS menus I was thinking of! I have looked back in one of my old programs and I have used them in menus, which must be why I had a memory of this.
Thanks for the tip Walt, does the DLL work for comboboxes as well? I don't have room for a listbox. It is because my combobox contents is so large and unwieldy that I was thinking of making it easier to read with dividers.
Pad the array? Do you mean with '--------' or similar?
|
|
|
Post by tsh73 on Apr 1, 2022 1:29:41 GMT -5
Coda, you better give some example We know how menu with divider looks basically it's a line that could not be celected Do you want something along
item 1 item 2 item 3 ------ (divider line, could not be selected) item 4 item 5
? "could not be selected" could be done in handling selection - say if current item starts with "-" just ignore it (WAIT in handler)
(I suspect LISTVIEW solution is about other kind of arrangement,
item 1 | item 2 longIitem 3 | item 4
)
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 1, 2022 3:05:33 GMT -5
Tsh73, yes, I was hoping to achieve your first example. The thing that complicates it is that currently the combobox index acts as one of the indices for a 2D array. I guess I can take care of that too, however, by subtracting the appropriate amount from each numbered item above the dividers...
|
|
|
Post by tsh73 on Apr 1, 2022 3:43:40 GMT -5
Have a look at this indexes to other array consealed into listbox item by appending after chr$(0)
nomainwin 'combo items 'chr$(0) conseals number used for linking to other arrays a$(1) = "one"+chr$(0)+"1" a$(2) = "two"+chr$(0)+"2" a$(3) = "------" 'divider line a$(4) = "three"+chr$(0)+"3" a$(5) = "four"+chr$(0)+"4"
'linked items b$(1) = "Linked one" b$(2) = "Linked two" b$(3) = "Linked three" b$(4) = "Linked four"
combobox #win.combo, a$(),[doCombo],10,10,120,200 texteditor #win.log, 140,10,150,290 BUTTON #win.btn, "Check", [doCombo], UL, 10, 100
open "Combobox Demo" for window as #win #win "trapclose [quit]" #win.combo "selectindex 1" wait
[quit] close #win end
[doCombo] #win.combo "selection? sel$" if left$(sel$,1)="-" then wait 'not active 'sel$ returns part after chr$(0) as well. Lets' split it idx=val(word$(sel$,2,chr$(0))) 'index sel$=word$(sel$,1,chr$(0)) 'visible part #win.log, "You chose ";sel$ #win.log, "linked to ";b$(idx) wait
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 1, 2022 7:44:45 GMT -5
That's ingenious! Thankyou. Just off the top of my head, I presume I could extend this functionality and prevent the user selecting the '------' at all if, instead of issuing a wait command, I remembered the previous non-line index state and forced the combobox to reselect this previous state on '------' selection. Without trying it, I'm thinking that would work. I'm very grateful for this, tsh73. Thankyou!
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 1, 2022 8:25:59 GMT -5
Lol... well, I can but then I'm back to my problem of having to skip indexes for the forced reselection process... I should have thought of that. ...and If I'm going to do that, I may as well just add +1 for every '------' below the current index, both on user selection and program forced reselection.
|
|
|
Post by Walt Decker on Apr 1, 2022 9:57:55 GMT -5
I was thinking more on the lines of this: ABCD EFGH IJKL MNOW XYA1 A1B1 than this: ABCE EFGH IJKL MNOP ------- QRST UVWX YZ12
What you are describing is combobox groups. There are API messages that will set up and define combobox groups, but you would have to use a dll in LB for them to be of any value. A way you can define the groups in a combobox is by perhaps having a key word or symbol preceding the group then indenting the group like this: A GROUP A1234 A4567 A5678 A9012 B GROUP BACKG BCKGN BKGNE BGINE
EDIT: OPPS, I hit the wrong button.
A listview control in the "API and DLL" thread is appropriate for multiple colunms but it can be used to define groups. Just put one group in column 1, the next group in column 2, the next group in column one, etc.
PS: If you want to select all the items in a group, just parse your array backwards until you find an un-indented key then select all items below that key until you come to another un-indented key. Remember that by default, comboboxes are single selection. You will have to change the style to multiple selection in order to high light all items in a group to give the user a chance to decide if that is really what s/he wants.
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 4, 2022 2:49:56 GMT -5
Ok, thanks heaps, Walt. I will look into this. I may have more questions when I do... lol. No, no, don't worry about that complication. This would all be separate selection. The grouping would just be for the purposes of making the contents easier to read and find things in for the end user.
|
|