Getting Started with WinForms DomainUpDown
The following tutorial demonstrates how to add items and images to a RadDomainUpDown and how to retrieve the selected text and image.
Add a RadDomainUpDown and a RadStatusStrip to a form.
Add a few flag images to the project as resources.
-
Using the down arrow of the RadStatusStrip, add a RadLabelElement and a RadButtonElement. Set the DisplayStyle of the RadButtonElement to Image.
-
Select RadDomainUpDown and find the Items property in the Properties Window of Visual Studio. Click the ellipsis button to open the RadListDataItem Collection Editor. Click the
Add
button three times to create three list items. Set the text of the first, second and third item to Bulgaria, Canada and Germany respectively. Set the resource images to the Image property of the items. Click OK to close the RadListDataItem Collection Editor.
Set the ReadOnly property to true for RadDomainUpDown.
In the Properties Window select the Events button.
Locate and double-click the SelectedIndexChanged event to create an event handler.
Paste the following code to the SelectedIndexChanged event handler. The code retrieves the selected item and assigns the text and image for the selected item to the status bar label and image elements.
Handling the SelectedIndexChanged event
private void radDomainUpDown1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
if (this.radDomainUpDown1.SelectedIndex > -1)
{
this.radLabelElement1.Text = this.radDomainUpDown1.SelectedItem.Text;
this.radButtonElement1.Image = this.radDomainUpDown1.SelectedItem.Image;
}
}
Private Sub radDomainUpDown1_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.Data.PositionChangedEventArgs)
If Me.radDomainUpDown1.SelectedIndex > -1 Then
Me.radLabelElement1.Text = Me.radDomainUpDown1.SelectedItem.Text
Me.radButtonElement1.Image = Me.radDomainUpDown1.SelectedItem.Image
End If
End Sub
This is it! Now the change in the selection of the RadDomainUpDown instance will be reflected on RadStatusStrip.
See Also
Telerik UI for WinForms Learning Resources
- Telerik UI for WinForms DomainUpDown Component
- Getting Started with Telerik UI for WinForms Components
- Telerik UI for WinForms Setup
- Telerik UI for WinForms Application Modernization
- Telerik UI for WinForms Visual Studio Templates
- Deploy Telerik UI for WinForms Applications
- Telerik UI for WinForms Virtual Classroom(Training Courses for Registered Users)
- Telerik UI for WinForms License Agreement)