You are watching: A control that combines the features of a text box and a list box is a ____.
The complying with Fig lists some of the common ComboBox properties and methods.
|Enabled||By establishing this building to True or False user deserve to decide whether user can communicate through this manage or not|
|Index||Specifies the Control selection index|
|List||String range. Contains the strings displayed in the drop-dvery own list. Starting array index is 0.|
|ListCount||Integer. Contains the number of drop-down list items|
|ListIndex||Integer. Contains the index of the selected ComboBox item. If an item is not schosen, ListIndex is -1|
|Locked||Boolean. Specifies whether user deserve to kind or not in the ComboBox|
|MousePointer||Integer. Specifies the shape of the mouse reminder as soon as over the location of the ComboBox|
|NewIndex||Integer. Index of the last item included to the ComboBox. If the ComboBox does not contain any kind of items , NewIndex is -1|
|Sorted||Boolean. Specifies whether the ComboBox"s items are sorted or not.|
|Style||Integer. Specifies the style of the ComboBox"s appearance|
|TabStop||Boolean. Specifies whether ComboBox receives the focus or not.|
|Text||String. Specifies the schosen item in the ComboBox|
|ToolTipIndex||String. Specifies what text is shown as the ComboBox"s tool tip|
|Visible||Boolean. Specifies whether ComboBox is visible or not at run time|
|AddItem||Add an item to the ComboBox|
|Clear||Removes all items from the ComboBox|
|RemoveItem||Removes the specified item from the ComboBox|
|SetFocus||Transfers emphasis to the ComboBox|
|Change||Called as soon as text in ComboBox is changed|
|DropDown||Called once the ComboBox drop-down list is displayed|
|GotFocus||Called once ComboBox receives the focus|
|LostFocus||Called as soon as ComboBox loses it focus|
Adding items to a List
It is possible to populate the list at architecture time or run time
Design Time : To add items to a list at architecture time, click on List building in the residential property box and then include the items. Press CTRL+ENTER after including each item as displayed below.
Run Time : The AddItem technique is provided to add items to a list at run time. The AddItem strategy offers the following syntaxation.
The item debate is a string that represents the message to include to the list
The index dispute is an integer that indicates wright here in the list to include the brand-new item. Not giving the index is not a trouble, bereason by default the index is assigned.
Following is an example to add item to a combo box. The code is typed in the Form_Load event
Private Below Form_Load()
Combo1.AddItem 1Combo1.AddItem 2Combo1.AddItem 3Combo1.AddItem 4Combo1.AddItem 5Combo1.AddItem 6
Rerelocating Items from a List
The RemoveItem approach is provided to rerelocate an object from a list. The syntaxation for this is given below.
The complying with code verifies that an object is schosen in the list and then clears the selected item from the list.
Private Sub cmdRemove_Click()If List1.ListIndex > -1 ThenList1.RemoveItem List1. ListIndexEnd IfEnd Sub
Sorting the List
The Sorted home is collection to True to allow a list to appear in alphanumeric order and also False to display the list items in the order which they are added to the list.
Using the ComboBox
A ComboBox combines the features of a TextBox and a ListBox. This permits the user to choose either by inputting text right into the ComboBox or by choosing an object from the list. There are three types of ComboBox layouts that are represented as displayed listed below.
Dropdown Combo (style 0)
Simple Combo (style 1)
Dropdvery own List (style 2)
The Simple Combo box displays an edit area with an attached list box constantly visible immediately below the modify area. A basic combo box display screens the contents of its list all the time. The user deserve to select a things from the list or kind an object in the modify box portion of the combo box. A scroll bar is displayed beside the list if tright here are too many kind of items to be displayed in the list box location.
The Dropdvery own Combo box first shows up as just an modify location through a down arrowhead button at the best. The list percentage remains concealed until the user clicks the down-arrowhead switch to drop dvery own the list percent. The user can either pick a worth from the list or type a value in the modify location.
The Dropdvery own list combo box turns the combo box into a Dropdvery own list box. At run time , the regulate looks like the Dropdown combo box. The user might click the dvery own arrowhead to see the list. The difference between Dropdown combo & Dropdown list combo is that the edit location in the Dropdown list combo is disabled. The user have the right to only pick an object and also cannot kind anything in the modify area. Anymethod this area displays the selected item.
This instance is to Add , Rerelocate, Clear the list of items and also ultimately cshed the application.
Open a new Standard EXE project is opened an named the Form as Listbox.frm and also save the task as Listbox.vbp
Deauthorize the application as presented below.
Go into a name
1 Fixed Single
The adhering to occasion steps are entered for the TextBox and CommandButton controls.
Private Sub txtName_Change()If (Len(txtName.Text) > 0) Then "Enabling the Add button"if atleastern one character"is enteredcmdAdd.Enabled = TrueEnd IfEnd Sub
Private Below cmdAdd_Click()lstName.AddItem txtName.Text "Add the entered the personalities to the list boxtxtName.Text = "" "Clearing the message boxtxtName.SetFocus "Get the emphasis ago to the"text boxlblDisplay.Caption = lstName.ListCount "Display the variety of items in the list boxcmdAdd.Enabled = False " Disabling the Add button
The click occasion of the Add switch adds the text to the list box that was typed in the Text box. Then the text box is cleared and also the focus is obtained to the message box. The variety of gotten in values will certainly is boosted according to the variety of items included to the listbox.
Private Sub cmdClear_Click()lstName.ClearlblDisplay.Caption = lstName.ListCountEnd Sub
Private Below cmdExit_Click()Unpack MeEnd Sub
Private Sub cmdRemove_Click()Dim remove As Integer
rerelocate = lstName.ListIndex "Getting the index
If rerelocate >= 0 Then "make sure an item is selected"in the list box
lstName.RemoveItem rerelocate "Remove item from the list boxlblDisplay.Caption = lstName.ListCount "Display the number of items"in the listbox
Remove button removes the selected item from the list as soon as you pressed the Rerelocate button. The variety of items is reduced in the listbox and the value is shown in the label.
See more: Why Is My Face Lighter Than My Body ? How To Shade Match Your Face And Body Skin Tone
The code for the clear switch gets rid of the listbox once you push it. And the number of items shown in the label becomes 0.