JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Using the ComboBox Class

As discussed in the In Depth section of this chapter, combo boxes combine a text box and a list box (which is why they're called combo boxes). In fact, combo boxes are derived from the ListBox class:

Object
   MarshalByRefObject
      Component
         Control
            ListControl
               ComboBox

You can find the more notable public properties of the ComboBox class in Table 7.7, the more notable methods in Table 7.8, and the more notable events in Table 7.9. Note that as with other Windows forms controls, I am not listing the notable properties, methods, and events ComboBox inherits from the Control class, such as the Click event—you can see all that in Chapter 5, Tables 5.1, 5.2, and 5.3.

Table 7.7: Noteworthy public properties of ComboBox objects.

Property

Means

DisplayMember

Indicates which property of the objects in the combo box to show. If empty, the combo box uses the ToString method.

DropDownStyle

Gets/sets the style of the combo box.

DropDownWidth

Gets/sets a combo box's drop-down part's width.

DroppedDown

Gets/sets if the combo box is displaying its drop-down part.

Focused

Gets a value specifying if the combo box has the focus.

IntegralHeight

Gets/sets if the combo box should resize so it doesn't show partial items.

ItemHeight

Gets the height of an item in a combo box.

Items

Gets a collection of the items in this combo box.

MaxDropDownItems

Gets/sets the maximum number of items visible in the drop-down part of a combo box.

MaxLength

Gets/sets the maximum number of characters in the combo box's text box.

SelectedIndex

Gets/sets the index of the currently selected item.

SelectedItem

Gets/sets currently selected item in the combo box.

SelectedText

Gets/sets the selected text in the text box part of a combo box.

SelectionLength

Gets/sets the number of characters selected in the text box part of the combo box.

SelectionStart

Gets/sets the beginning index of selected text in the combo box.

Sorted

Gets/sets if the items in the combo box are sorted.

Table 7.8: Noteworthy public methods of ComboBox objects.

Method

Means

BeginUpdate

Turns off visual updating of the combo box until the EndUpdate method is called.

EndUpdate

Resumes visual updating of the combo box.

FindString

Finds the first item in the combo box that begins with the indicated string.

FindStringExact

Finds the item that matches the indicated string exactly.

GetItemText

Gets an item's text.

Select

Selects a range of text.

SelectAll

Selects all the text in the text box of the combo box.

Table 7.9: Noteworthy public events of ComboBox objects.

Event

Means

DropDown

Occurs when the drop-down portion of a combo box is shown.

DropDownStyleChanged

Occurs when the DropDownStyle property has changed.

SelectedIndexChanged

Occurs when the SelectedIndex property has changed.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor