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

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.

    domainUpDown1.Dispose();
    

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

    domainUpDown1.DoubleClick+=new EventHandler(domainUpDown1_DoubleClick);
    

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

    domainUpDown1.DownButton();
    

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

    domainUpDown1.Enabled = true;
    

    "Focus()" focusing the domainUpDown control.

    domainUpDown1.Focus();
    

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

    domainUpDown1.Height=400;
    

    "Hide()" hides the domainUpDown control.

    domainUpDown1.Hide();
    

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

    domainUpDown1.Items.Add(1);
    

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

    List<string> li=new List<string>();
    li.Add("1");
    li.Add("2");
    domainUpDown1.Items.AddRange(li);
    

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

    domainUpDown1.Items.Remove("1");
    

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

    domainUpDown1.Items.RemoveAt(1);
    

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

    if (domainUpDown1.Items.Contains("1"))
    {
      MessageBox.Show("Yes, is it available");
    }
    else
    {
      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);
    if(e.KeyCode==Keys.Down)
    {
       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.

    domainUpDown1.ResetText();
    

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

    domainUpDown1.Show();
    

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

    domainUpDown1.Sorted = true;
    


Write a comment


Name Email Message