TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

DomainUpDown Control Example

This C# tutorial provides an example for the DomainUpDown control in Windows Forms.

DomainUpDown. How can you present a limited selection of options?

This should use only minimal screen space. In Windows Forms, you can provide a DomainUpDown control, which allows users to select one of several items.

Example. First, to add a DomainUpDown control, drag it from the Toolbox to the Window. A good place to initialize the DomainUpDown control is in the Load event of the enclosing form. Please double-click on the enclosing form to create this event.

Next: We add several items to the DomainUpDown control. The current item can be determined or set with the Text property.

C# program that uses DomainUpDown control

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
	public Form1()
	{
	    InitializeComponent();
	}

	private void Form1_Load(object sender, EventArgs e)
	{
	    // Items.
	    DomainUpDown.DomainUpDownItemCollection items = this.domainUpDown1.Items;
	    items.Add("Dot");
	    items.Add("Net");
	    items.Add("Perls");

	    // Set Text.
	    this.domainUpDown1.Text = "Dot";
	}

	private void domainUpDown1_SelectedItemChanged(object sender, EventArgs e)
	{
	    // Run code every time the item is changed.
	    this.Text = domainUpDown1.Text;
	}
    }
}

SelectedItemChanged event handler. Every time the selected item is changed by the user, this code is executed. In the above example program, we set the Text property of the Form to the current item in the DomainUpDown.

Property

 

Summary. The DomainUpDown control provides an alternative to radio buttons or other pull-down lists. It is a very simple user interface control but can be useful in a variety of program contexts, including preferences dialogs (Options).


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf