In this blog post, you will learn more about the DomainUpDown control in Telerik UI for WinForms and how to use it to build a selection list for countries.
RadDomainUpDown in Telerik UI for WinForms is a combination of a text-box and a pair of moving up and down buttons to navigate through a limited selection of options. This control may save you some screen space since it occupies the space needed for a standard text-box. However, in addition, it allows the end user to select one of a variety of several items.
A common use-case is to build an input form for filling personal information. One of the required fields is the nationality. RadDomainUpDown is suitable for introducing the countries options if you don’t want to allocate a lot of space on the form.
You can add the country items either at design time or at run time.
The RadListDataItem Collection Editor allows you to do that. You can access it through the Smart tag >> Edit Items option:
For each country option, add a RadListDataItem to the Items collection that RadDomainUpDown offers:
Open the project’s Resources and add the flags for the countries that you have added:
Open the RadListDataItem Collection Editor again and assign an image to each RadListDataItem:
Set the Image property for each RadListDataItem:
The last thing to do is to set the ReadOnly property to true. Thus, the item’s image will be shown next to the text after making a selection:
Set the Wrap property to true if you need the selected item to revert to the first item after reaching the last item and vice versa.
The SelectedIndexChanging event allows you to control whether the newly selected item is valid according to the other fields’ input, e.g. selected town. If the selection is not valid simply set the Cancel argument to true:
You can learn more about the Telerik UI for WinForms suite via the product page. It comes with a 30-day free trial, giving you some time to explore the toolkit and consider using it for your current or upcoming WinForms development.
We would love to hear what you think, so should you have any questions and/or comments, please share them to our Feedback Portal.
Desislava Yordanova is currently a Senior Technical Support Engineer in the Telerik UI for WinForms team. She joined the company in 2013 after graduating from Telerik Academy. Desislava holds a master’s degree in Computer Systems and Technologies from the Technical University in Sofia. Apart from her job, she is keen on snowboarding and travelling. You can find Desislava on LinkedIn.
Subscribe to be the first to get our expert-written articles and tutorials for developers!