BB___COMBOBOX

=COMBOBOX= toc

Description
> A COMBOBOX is a //control// on a GUI window that consists of a drop-down list and a textbox field. The selection chosen from the list is displayed in the textbox. > Comboboxes are similar to Listboxes, but use less space.

Syntax notes

 * //**#handle.ext**// Must be a unique .extension so commands can be written to control after window is opened.
 * //**array$**// The string array contains the items that are displayed in the combobox drop-down list //after// the window is opened.
 * //**eventHandler**// The branch label or subroutine where program flow continues //after// an item is selected from the combobox drop-down list.
 * //**x, y**// The x and y coordinates which position the combobox from the upper left corner of the window.
 * //**wide and high**// The width of the control. Height is the length of the drop-down list (in pixels) when the list is open - this parameter is ignored from Win XP up. (The height of the closed combobox, the textbox field, is dependant on the font used.)

Combobox Features

 * //**Selecting an Item.**// The user can select from the drop-down list by clicking an item. The user can also select by typing into the textbox field. The listed match will become the selection.
 * //**Loading the Array.**// To display items in the combobox, the array must be loaded before the window is opened. The array may be loaded by coding the literal strings in the program listing, by using DATA and READ statements, or by inputting data from a disk file.
 * //**Changing the Contents of the List.**// To add or remove an item from the combobox, you must add it or remove it to/from the array. Before the change will show up in the combobox drop-down list, a RELOAD command must be issued. Issuing a RELOAD at any time updates the contents of the combobox.
 * //**Width and Height of Drop-down List.**// When open, the combobox height automatically adjusts to display all the items ("high" parameter is ignored from Win XP and up). Then making long list, vertical scroll bar appears. The width does not increase if an item is longer than what is specified in **wide** parameter. Horisontal scroll bars are not provided in comboboxes.

Combobox Commands
The following commands (Methods) can be used with combobox controls. See the individual pages for discussion. print #handle.ext, "contents? varName$" print #handle.ext, "disable" print #handle.ext, "enable" print #handle.ext, "font fontName pointsize" print #handle.ext, "reload" print #handle.ext, "select string" print #handle.ext, "selectindex i" print #handle.ext, "selection? selected$" print #handle.ext, "selectionindex? index" print #handle.ext, "setfocus"

Combobox Variables
The following variables can be used with combobox controls. See the individual pages for discussion. ComboboxColor$

Example
From JustBASIC Help file

code format="lb" nomainwin a$(1) = "one" a$(2) = "two" a$(3) = "three" a$(4) = "four"
 * A combobox demo with branch label event handler.**

combobox #win.combo, a$,[doCombo],10,10,120,200 open "Combobox Demo" for window as #win
 * 1) win "trapclose [Quit]"
 * 2) win.combo "selectindex 1"

wait

[Quit] close #win:end

[doCombo] notice "You chose ";sel$ wait code
 * 1) win.combo "selection? sel$"

code format="lb" nomainwin a$(1) = "one"
 * A combobox demo with subroutine event handler.**

a$(2) = "two" a$(3) = "three" a$(4) = "four"

combobox #win.combo, a$,doCombo,10,10,120,200

open "Combobox Demo" for window as #win
 * 1) win "trapclose Quit"
 * 2) win.combo "selectindex 1"

wait

sub Quit handle$ close #handle$ end end sub

sub doCombo handle$ notice "You chose ";sel$ end sub code
 * 1) handle$ "selection? sel$"

Useful Functions
code format="vbnet" Place a useful function using this command here code