Download A Beginner`s Guide to Gambas
Transcript
A Beginner's Guide to Gambas DIM hComboBox AS ComboBox To instantiate the variable we just declared, use this format: hComboBox = NEW ComboBox ( Parent AS Container ) This will create a new ComboBox control. This class acts like a readonly array. In other words, declaring the variable, instantiating it, and retrieving a value from code directly would work like this: DIM hComboBox AS ComboBox DIM hComboBoxItem AS .ComboBoxItem DIM Index as Integer hComboBoxItem = hComboBox[Index] The line of code above will return a combobox item from its integer index. Note that the .ComboBoxItem represents an item in the combobox popup list box. This class is virtual. You cannot use it as a datatype and it is not creatable. It has a single property, Text which returns a string value representing the ComboBox item represented by Index. We are going to create a ComboBox on our form now. Here is what our control will look like: Figure 30 Our ComboBox. OK, i agree that it is nothing very fancy and it probably ranks kind of low on the creativity list, but it will get the job done and teach you what you need to know to use ComboBoxes. To build our new control, we will go to the Gambas ToolBox and select the ComboBox control. Place it on the form (refer to our initial Figure at the very beginning of this chapter to see where it should go) and try to get it as close to what you see in that picture as you can. Once you are done with that, click on it once if you do not see the handles and go to the Properties Window. Find the List property. The input box to the right of this will enable a 86