DomainUpDown

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
Exam Prep. Guides
70-505 Study Guide
70-526 Study Guide

1. Forms Controls

2. Integrating Data
3. Printing/Reporting
4. Enhancing Usability
5. Asynchronous Prog.
6. Forms Controls
7. Configure/Deploy

edit
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.

Image:526-107.jpg


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 the DomainUpDown.
  • 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 Image:ellipsesbutton.gif button in the right hand column of the Items property in the Properties Window.

Image:526-108.jpg


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


Previous_Page_.gif Next_Page_.gif
© 2007-2008 Mike Kitchen

Today's Deals: Electronics

Personal tools