DomainUpDown Control in VB.NET
The Windows Forms DomainUpDown control looks like a combination of a text box and a pair of buttons for moving up or down through a list. The control displays and sets a text string from a list of choices. The user can select the string by clicking up and down buttons to move through a list, by pressing the UP and DOWN ARROW keys, or by typing a string that matches an item in the list. One possible use for this control is for selecting items from an alphabetically sorted list of names. (To sort the list, set the Sorted property to true.) The function of this control is very similar to the list box or combo box, but it takes up very little space.
The key properties of the control are Items, ReadOnly, and Wrap. The Items property contains the list of objects whose text values are displayed in the control. If ReadOnly is set to false, the control automatically completes text that the user types and matches it to a value in the list. If Wrap is set to true, scrolling past the last item will take you to the first item in the list and vice versa. The key methods of the control are UpButton and DownButton.
This control displays only text strings. If you want a control that displays numeric values, use the NumericUpDown control.
Here is the way to add items in the control
Sub Add_Cities_To_DropDown()
DomainUpDownSource.Items.Add("
DomainUpDownSource.Items.Add("
DomainUpDownSource.Items.Add("Chennai")
DomainUpDownSource.Items.Add("
DomainUpDownSource.Items.Add("
DomainUpDownSource.Items.Add("
DomainUpDownSource.Sorted = True
DomainUpDownSource.ReadOnly = True
End Sub
Selected Items can be retrieved through Text property:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sBoardingCity As String
Dim sDestnCity As String
sBoardingCity = DomainUpDownSource.Text
sDestnCity = DomainUpDownDestn.Text
End Sub
SelectedItemChanged event can be trapped to dynamically generate output based on selected text
Private Sub DomainUpDownSource_SelectedItemChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DomainUpDownSource.SelectedItemChanged
GetDestination(DomainUpDownSource.Text)
End Sub
No comments:
Post a Comment