DomainUpDown


The DomainUpDown control displays a list of items that the user can select by clicking the up and down arrow buttons beside the control. For example, the control might let the user select one of the values High, Medium, and Low.

If the control’s InterceptArrowKeys property is True, the user can also scroll through the items by using the up and down arrow keys. If InterceptArrowKeys is False, then the user must click the arrow buttons to change the value.

Normally, the control’s ReadOnly property is set to False so the user can type text into the control’s text area much as you can enter text in a ComboBox. If ReadOnly is True, then the user cannot type in this area and must use the arrow keys or buttons to pick one of the control’s items. Unfortunately, setting ReadOnly to True gives the control a gray background, so it appears disabled unless you look closely and notice that the text is black rather than dark gray.

Like the CheckedListBox control, the DomainUpDown control can hold arbitrary objects as items. It displays the string returned by an object’s ToString method. See the “CheckedListBox” section earlier in this appendix for more information about displaying objects in the control.

The control’s SelectedItem property returns the object representing the item that is currently selected. Note that there may be no item selected if the user typed a value in the text area, rather than selecting a value from the list of items. The SelectedIndex property returns the index of the currently selected item or -1 if no choice is selected.

The control’s Text property returns the text that the control is currently displaying. This property returns something meaningful whether the user typed a value or selected an item from the list.

When the control is first displayed, no item is selected. You can use the Properties window to give the control a Text value at design time but you cannot make it select an item, even if the Text value matches an item’s text. If you want the control to begin with an item selected, you can use code similar to the following in the form’s Load event handler:

  ' Select the first Priority value. dudPriority.SelectedIndex = 0 

If you set the control’s Sorted property to True, then the control displays its items in sorted order.

If you set the Wrap property to True, then the control wraps its list of items around if the user moves past the beginning or end of the list.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net