DomainUpDown
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| Exam 70-526 Preparation Guide: Configure the layout and functionality of a Windows Form to display a list of items |
Contents |
The DomainUpDown control is similar to the NumericUpDown control, with the difference being that the DomainUpDown displays a list of strings and the NumericUpDown control displays a list of numbers.
Inheritance hierarchy
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ScrollableControl
System.Windows.Forms.ContainerControl
System.Windows.Forms.UpDownBase
System.Windows.Forms.DomainUpDown
Useful properties
-
Items- The collections of strings that can be displayed and chosen from.
-
-
ReadOnly- Indicates whether the text can be changed by the use of the up or down buttons only.
-
-
SelectedIndex- Indicates the index value of the selected item.
-
-
SelectedItem- Indicates the selected item based on the index value of the selected item in the collection.
-
-
Sorted- Indicates whether the item collection is sorted.
-
-
Text- The text that is displayed in theDomainUpDown.
-
-
Wrap- Indicates whether the collection of items continues to the first or last item if the user continues past the end of the list.
-
String Collection Editor
The Items can be edited using the String Collection Editor, which can be accessed by clicking on the
button in the right hand column of the Items property in the Properties Window.
Adding a DomainUpDown manually
Consider adding a DomainUpDown that allows items of food to be selected. The code to do this would be similar in nature to this example:
public void AddDomainUpDown() { DomainUpDown domUpDn = new DomainUpDown(); domUpDn.Location = new Point(50, 50); domUpDn.Size = new Size(100, 25); domUpDn.Items.Add("Spaghetti"); domUpDn.Items.Add("Corn"); domUpDn.Items.Add("Potatoes"); domUpDn.Items.Add("Tomatoes"); domUpDn.SelectedItem = "Corn"; Controls.Add(domUpDn); }
SelectedItemChanged Event
The crucial event behind the DomainUpDowncontrol is the SelectedItemChanged event.
For the SelectedItemChanged event to occur, the SelectedItem property can be changed in code, by the user typing in a new value or clicking the control's up or down buttons.
MSDN references
|



