MMCC MASTHEAD
Mid-Michigan Computer Consultants - Bay City, Michigan
 


CONTENTS       (old style)
Mid-Michigan Computer Consultants
509 Center
Bay City, Michigan

Sales (989) 892-9242
Support (989) 686-8860

Plb-0250.cfm v1.0


plb-t010.cfm
 

ANSI Standard PL/B Language and Visual PL/B

Combo Box

NOTE TO OUR READERS
This web resource is written for our own use. But we feel strongly that the PL/B language should be shared with the software community. So feel free to use this at will! BUT PLEASE... if you find errors or omissions or have a better way to do something. TELL US! Dialog helps us all. Send e-mail to: support@mmcctech.com

A combo box is one of those one liners with a DOWN ARROW on the right end. When you click the down arrow you get a table of things you can do.

LIST SIZE: In the designer you set the length of the dropdown by clicking on the ListData property. That gives you a window and you can add items for the initial list. You can also add blank lines to just set the size of the dropdown.

Thst sets the screen dropdown size only. You can put a ton of items into the actual list. Not sure what the limit is.

STYLE: There are three values for ComboStyle
Dropdown Edit: allows the user to enter ANYTHING in to the field. It doesn't have to be in the list.

Dropdown List: You can key something but it has to be in the list. If you key the first letter the list will auto jump to that item. Really nice. The item MUST be in the list.

Simple: You can ONLY use the drop down to select the value and the value, by definition, must be in the list.


Multi-select This should be possible. It can be done in HTML. But we have NOT found a technique for the form designer.

ComboBox.DIR method

This method works the same as the DataList.DIR works.
Use the menu item on the left to go to that section.

LOADING THE LIST

You can, of course, pre-load the list from the designer as mentioned above.

In the program you LOAD the initial values of the Combo box like this:
     DELETEITEM    {combobox}, 0            ; Clear entire list

     INSERTITEM    {combobox},99999,{data}  ; Insert at END of the list

     INSERTITEM    {combobox},nnn,  {data}  ; Insert at a specific line
	 
     SETITEM       {combobox},0, nnn        ; Selects the item for line nnn
	 

You can do a loop with a specific index value ("nnn") to fill the list. That is,
        MOVE          ZERO,IX1               ; Initialize the index
        LOOP
          ADD         ONE, IX1               ; increment index
          INSERTITEM  {combobox},IX1,{data}  ; Put {data} in line IX1
          IF (some condition is true)
              SETITEM {combobox},0,IX1       ; Select this item
          ENDIF
        REPEAT UNTIL {condition}
You can also loop and use the 99999 to tack onto the end of the list.
        LOOP
          INSERTITEM  {combobox},99999,{data}  ; Put {data} in LAST line
        REPEAT UNTIL {condition}

Use the specific index technique if you want to remember where a specific item is stored. For example: Say that you load a list with salesmen. When done you want to position to a particular person. To do this you load the list to specific locations looking for "your" salesman. When you find that person, you remember the index number.
        MOVE          ZERO,IX1               ; Initialize the index
        MOVE          ZERO,OURGUY            ; Don't know which line
        LOOP
          ADD         ONE, IX1               ; increment index
          INSERTITEM  {combobox},IX1,{data}  ; Put {data} in line IX1
          IF ({data} = {our salesman})       ; Is this our guy?
              MOVE    IX1, OURGUY            ; When true, remember IX1
          ENDIF
        REPEAT UNTIL {condition}
        SETITEM       {combobox},0,OURGUY    ; Point to our salesman


POINTING TO AN ENTRY:

As mentioned above, you may want to pre-set the list to point to a specific line. Do that with the SETITEM as follows:
        SETITEM {combobox},0,{index}    ; Point to line at {index}


GETTING DATA OUT OF THE LIST:

You retreive data from the combobox with a standard GETITEM instruction. What you get depends on the STYLE of the list and how you code the GETITEM instruction.

The first parameter to the GETITEM names the combobox object that you're working with.

The SECOND parameter is the number of the list item that you want. The value will be zero if either it doesn't matter (example 1 below) or when you're asking for the value of the top entry (example 3).

The third parameter's type determines how the instruction works. If the third item is a CHARACTER STRING you'll get data from the list. If the third item is a NUMBER you'll get the index to the line that was clicked.

The STYLE comes into play on the third example below. For an EDIT style list (where the user can key anything into the combobox's top line), you can use index ZERO to get the top line as it appears to the user.
    GETITEM {combobox}, 0,   {numeric}   Gets the index of currently
                                         active item in the list



GETITEM {combobox}, nnn, {string} Gets the contents of the entry number "nnn".

GETITEM {combobox}, 0, {string} Get the actual value keyed but only if this is a style EDIT where they can put anything in the field.


FORMATTING THE COMBOBOX:

Combobox contents are simple strings. You can load a list with data like this.
        LOOP
          PACK        WORK_STRING,ID, NAME, ADDRESS ; build string
          INSERTITEM  {combobox},999999,WORK_STRING ; put in list
        REPEAT UNTIL {condition}
The above list will not produce nice columns of data as you might expect UNLESS you control the font. If you use a proportional font the data will appear like this:

101 John Jones 600 Lakeshore Drive
101 Larry Lewis 1420 Mountain
103 Susie Sunshine 980 Summer Circle
 
To arrive at nice columns you must use a FIXED font such as Courier. You can select the font when building the form in the forms designer.
         101   John Jones         600 Lakeshore Drive
         101   Larry Lewis       1420 Mountain
         103   Susie Sunshine     980 Summer Circle



v1.10

Write to MMCC Technical Support at:               Send e-mail to MMCC.
MMCC - Technical Support
600 W. Midland
Bay City, MI 48708
(989) 686-8860
© 1997 - 2017 MMCC - All Rights Reserved