Home » VB.NET ComboBox Control

VB.NET ComboBox Control

by Online Tutorials Library

VB.NET ComboBox Control

The ComboBox control is used to display more than one item in a drop-down list. It is a combination of Listbox and Textbox in which the user can input only one item. Furthermore, it also allows a user to select an item from a drop-down list.

Let’s create a ComboBox control in the VB.NET Windows by using the following steps.

Step 1: We need to drag the combo box control from the toolbox and drop it to the Windows form, as shown below.

VB.NET ComboBox Control

Step 2: Once the ComboBox is added to the form, we can set various properties of the ComboBox by clicking on the ComboBox control.

ComboBox Properties

There are following properties of the ComboBox control.

VB.NET ComboBox Control

Property Description
AllowSelection The AllowSelection property takes the value that indicates whether the list allows selecting the list item.
AutoCompleteMode It takes a value that represents how automatic completion work for the ComboBox.
Created It takes a value that determines whether the control is created or not.
DataBinding It is used to bind the data with a ComboBox Control.
BackColor The BackColor property is used to set the background color of the combo box control.
DataSource It is used to get or set the data source for a ComboBox Control.
FlatStyle It is used to set the style or appearance for the ComboBox Control.
MaxDropDownItems The MaxDropDownItems property is used in the combo box control to display the maximum number of items by setting a value.
MaxLength It is used by the user to enter maximum characters in the editable area of the combo box.
SelectedItem It is used to set or get the selected item in the ComboBox Control.
Sorted The Sorted property is used to sort all the items in the ComboBox by setting the value.

ComboBox Events

Events Description
FontChanged It occurs when the property of the font value is changed.
Format When the data is bound with a combo box control, a format event is called.
SelectIndexChanged It occurs when the property value of SelectIndexChanged is changed.
HelpRequested When the user requests for help in control, the HelpRequested event is called.
Leave It occurs when the user leaves the focus on the ComboBox Control.
MarginChanged It occurs when the property of margin is changed in the ComboBox control.

Let’s create a program to display the Calendar in the VB.NET Windows Form.

ComboBox_Control.vb

Output:

VB.NET ComboBox Control

Now select the day, month, and year from dropdown box and then click on the Date button to display the date in the form.

VB.NET ComboBox Control


Next TopicListBox Control

You may also like