Raises the System.WinForms.DomainUpDown.SelectedItemChanged event.
[Visual Basic] Protected Sub OnSelectedItemChanged( _ ByVal source As Object, _ ByVal e As EventArgs _ ) [C#] protected void OnSelectedItemChanged( object source, EventArgs e ); [C++] protected: void OnSelectedItemChanged( Object* source, EventArgs* e ); [JScript] protected function OnSelectedItemChanged( source : Object, e : EventArgs );
Raising an event invokes the event-handling method through a delegate. For an overview, see [DelegateTopicTBD].
Notes to Inheritors: When overriding OnSelectedItemChanged in a derived class, be sure to call the base class's OnSelectedItemChanged method.
The following example instantiates and initializes a DomainUpDown control. The example allows you to set some of its properties and create a collection of strings for display in the up-down control. The code assumes that a Label, TextBox, two CheckBox controls and two Button controls have been instantiated on a form. Label the CheckBox controls as System.WinForms.DomainUpDownItems.Sorted and System.WinForms.DomainUpDownItems.Wrap and the buttons as Add Item and Add Collection. This example will allow you to add an item to an array each time the Add Item button is clicked and also add the contents of the array to the System.WinForms.DomainUpDownItems.Items collection.
[Visual Basic]
' Instantiate the DomainUpDown control. Private DomainUpDown1 As System.WinForms.DomainUpDown Private myArray() as String Private myCounter as Integer Private Sub MySub() ' Initialize the DomainUpDown control. Set Me.DomainUpDown1 = New System.WinForms.DomainUpDown End Sub ' Add Collection button. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Assign the array contents to the DomainUpDown control. DomainUpDown1.Items.All = myArray End Sub ' Add Item button. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Re-dimension the array size by one. ReDim Preserve myArray(myCounter + 1) ' Assign the user's value to the array element, concatenate the counter value. Set myArray(myCounter) = trim(TextBox1.Text) & " - " & myCounter ' Increment the counter variable. myCounter = myCounter + 1 'Clear the TextBox. TextBox1.Text = "" End Sub Private Sub CheckBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ' If Sorted is set to true, set it to false; otherwise set it to true. If DomainUpDown1.Sorted = True Then DomainUpDown1.Sorted = False Else DomainUpDown1.Sorted = True End If End Sub Private Sub CheckBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ' If Wrap is set to true, set it to false; otherwise set it to true. If DomainUpDown1.Wrap = True Then DomainUpDown1.Wrap = False Else DomainUpDown1.Wrap = True End If End Sub Private Sub DomainUpDown1_SelectedItemChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Display the SelectedIndex & SelectedItem property values in the label. Label1.Text = "SelectedIndex: " & DomainUpDown1.SelectedIndex & vbcrlf & _ "SelectedItem: " & DomainUpDown1.SelectedItem End Sub
DomainUpDown Class | DomainUpDown Members | System.WinForms Namespace | SelectedItem | System.WinForms.DomainUpDown.SelectedItemChanged