View previous topic :: View next topic |
Author |
Message |
flypaper Contributor
Joined: 19 Oct 2001 Posts: 104
|
Posted: Tue Mar 19, 2002 2:48 pm Post subject: Help! Combo boxes? |
|
|
I've never used one before, so please excuse my lameness. How do I get a list into the combo box? I think I've looked over the help and the examples, and am unable to find documentation on this. What am I missing? |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Mar 19, 2002 3:05 pm Post subject: |
|
|
Just create your combo element, let's say named COMBO1. Then load your
stuff into the combo like this:
Load the content of a file:
Code: | list loadfile,COMBO1,file.txt |
Or load the contents of a list (here list 3)
Code: | list assign,COMBO1,3 |
Hope it helps
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
flypaper Contributor
Joined: 19 Oct 2001 Posts: 104
|
Posted: Tue Mar 19, 2002 4:32 pm Post subject: |
|
|
After I do the Code: | list assign, combo1, 1 | is there a way to make the top one in the list the default? When I do it now, the combo box is blank until I select one. |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Mar 19, 2002 4:53 pm Post subject: |
|
|
Sure thing!
One way of doing it would be this:
Code: | LIST SEEK,3,0
%%listitem = @ITEM(3)
dialog set,COMBO1,%%listitem |
That would enter item No. 1 in your list (still list 3) into the combo dialog.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
flypaper Contributor
Joined: 19 Oct 2001 Posts: 104
|
Posted: Tue Mar 19, 2002 5:15 pm Post subject: |
|
|
That's basically what I tried but it doesn't work. Here's what I have. What am I doing wrong?
Code: | DIALOG ADD,COMBO,COMBO1,28,77,182,21,,click,list
list create, 1
list create, 2
list loadfile, 1, @path(%0)list.txt
REPEAT
parse "%D;%E;%F", @next(1)
list add, 2, %D
UNTIL @equal(@index(1),@count(1))
list assign, combo1, 2
list seek, 2, 0
DIALOG set, combo1, @item(2) |
If needed the list.txt file contains various info I need later in the form of test|123|456
EDIT - The above works if I take the 'list' style off the combo box. However, is there a way to do it with the 'list' style on? |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Mar 19, 2002 7:17 pm Post subject: |
|
|
Hmmmm. If you are using the LIST style, it might be a problem because
with LIST the combo box does not allow you to enter data into the control
- you can just choose values from the drop down list.
And I just made a small test, and the LIST style also blocks using a Win
API call to change the combo box text. Without the LIST style, this also
should work:
Code: | %%dummy = @sendmsg(@win(~COMBO1),$0C,0,NewComboText) |
If I think of something else, I'll let you know
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Mar 19, 2002 8:32 pm Post subject: |
|
|
Sorry to intrude, but If you want to set the combo box
to an item in the combo, you can just use the seek command:
list seek,combo1,<item #>
or if you do not know the index of the item
you can do and @match() for the item and
if the Item is found, the combo will be set
to that index. Here is an example:
Code: |
DIALOG CREATE,Combo demo,-1,0,240,93
DIALOG ADD,COMBO,COMBO1,18,38,180,21,,,list
DIALOG ADD,BUTTON,BUTTON1,56,76,76,24,Set to Item 3
DIALOG SHOW
List add,combo1,"Item 0"
List add,combo1,"Item 1"
List add,combo1,"Item 2"
List add,combo1,"Item 3"
List add,combo1,"Item 4"
List add,combo1,"Item 5"
List add,combo1,"Item 6"
list seek,combo1,0
:evloop
wait event
goto @event()
:close
stop
:button1button
list seek,combo1,0
%m = @match(combo1,"Item 3")
goto evloop
|
hope that helps. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Mar 19, 2002 9:44 pm Post subject: |
|
|
Yeah, Chris ! Of course, that's the way to do it when the combo is a list.
It was sitting right under my nose, but I didn't think of it.
Keep 'em coming.
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
flypaper Contributor
Joined: 19 Oct 2001 Posts: 104
|
Posted: Wed Mar 20, 2002 8:52 pm Post subject: |
|
|
That did it. Thanks guys!! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|