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
PropertyDescription
AllowSelectionThe AllowSelection property takes the value that indicates whether the list allows selecting the list item.
AutoCompleteModeIt takes a value that represents how automatic completion work for the ComboBox.
CreatedIt takes a value that determines whether the control is created or not.
DataBindingIt is used to bind the data with a ComboBox Control.
BackColorThe BackColor property is used to set the background color of the combo box control.
DataSourceIt is used to get or set the data source for a ComboBox Control.
FlatStyleIt is used to set the style or appearance for the ComboBox Control.
MaxDropDownItemsThe MaxDropDownItems property is used in the combo box control to display the maximum number of items by setting a value.
MaxLengthIt is used by the user to enter maximum characters in the editable area of the combo box.
SelectedItemIt is used to set or get the selected item in the ComboBox Control.
SortedThe Sorted property is used to sort all the items in the ComboBox by setting the value.

ComboBox Events

EventsDescription
FontChangedIt occurs when the property of the font value is changed.
FormatWhen the data is bound with a combo box control, a format event is called.
SelectIndexChangedIt occurs when the property value of SelectIndexChanged is changed.
HelpRequestedWhen the user requests for help in control, the HelpRequested event is called.
LeaveIt occurs when the user leaves the focus on the ComboBox Control.
MarginChangedIt 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




Latest Courses