domainUpDown Control in C#

In this article, we will learn how to use domainUpDown in windows form in C#.

Let's create windows form.

Step 1
In Visual Studio select "File" = > "New" = > "Project..." then select C# Windows Forms Application then click Ok.

create windows form

Step 2
Let's create a domainUpDown then you go "View" = > select "ToolBox" (Crtl+Alt+X) = > then select "All Windows Forms" = > Choose "domainUpDown".

  1. First of all, we'll know about the "domainUpDown".

    domainUpDown display a single string value that the user selected from a list of items by clicking up and down buttons in the control. We'll discuss about properties and function and events of domainUpDown write down.

    "BackColor" changes the background color of domainUpDown control.

    domainUpDown1.BackColor = Color.AliceBlue;

    "BorderStyle" changes the border style of domainUpDown control.

    domainUpDown1.BorderStyle = BorderStyle.Fixed3D;

    "Click" when user mouse click on domainUpDown control.

    domainUpDown1.Click+=new EventHandler(domainUpDown1_Click);

    "Cursor" when user mouse hover on domainUpDown control then cursor style changed.

    domainUpDown1.Cursor = Cursors.Hand;

    "Dispose()" released all resources used by the System.ComponentModel.Component.


    "DoubleClick" when user mouse double click on domainUpDown control.

    domainUpDown1.DoubleClick+=new EventHandler(domainUpDown1_DoubleClick);

    "DownButton()" displays the next item of domainUpDown object collection.


    "Enabled" changes the domainUpDown control are enable or not.

    domainUpDown1.Enabled = true;

    "Focus()" focusing the domainUpDown control.


    "Font" changes the style of the text of domainUpDown control.

    domainUpDown1.Font = new System.Drawing.Font("arial", 14.0F, FontStyle.Bold);

    "ForeColor" changes the font color of domainUpDown control.

    domainUpDown1.ForeColor = Color.AliceBlue;

    "Height" set the height of domainUpDown control.


    "Hide()" hides the domainUpDown control.


    "Items.Add()" adding one items in the domainUpDown control.


    "Items.AddRange()" adding multiple item in the domainUpDown control.

    List<string> li=new List<string>();

    "Items.Remove()" removes the items of domainUpDown control.


    "Items.RemoveAt()" removes at which index number would you want in domainUpDown control.


    "Items.Contains" checks items are available or not in domainUpDown control.

    if (domainUpDown1.Items.Contains("1"))
      MessageBox.Show("Yes, is it available");
      MessageBox.Show("Nop, is it not available");

    "Items.Count" counts all items there are present in the domainUpDown control.

    int i=domainUpDown1.Items.Count;

    "KeyDown" events are working when user press any key from keyboard.

    domainUpDown1.KeyDown+=new KeyEventHandler(domainUpDown1_KeyDown);
       domainUpDown1.SelectedIndex += 1;
    else if (e.KeyCode == Keys.Up)
       domainUpDown1.SelectedIndex -= 1;

    "ReadOnly" access only on read only not write on domainUpDown control.

    domainUpDown1.ReadOnly = true;

    "ResetText()" resets all items of domainUpDown to its default values.


    "SelectedIndex" gets or sets the index of selected item.

    domainUpDown1.SelectedIndex = 0;

    "SelectedItem" gets or sets the selected item based on the index value of the selected item in the collection.

    domainUpDown1.SelectedItem = "1";

    "Show()" displays the domainUpDown control.


    "Sorted" gets or sets the items collection sorted or not of the domainUpDown control.

    domainUpDown1.Sorted = true;

Write a comment

Name Email Message