Event firing twice in UserControl issue

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have a user control (from Microsoft which originally was simply a control
with no panel) with a panel then a custom ListControl. I want to be able to
trap SelectedValueChanged event of the ListControl. The code shown below
works but fires off the event twice, any thoughts?

Imports System.ComponentModel
Public Class RadioButtonListPanel

Public Event selectedvaluechanged(ByVal sender As Object, ByVal e As
System.EventArgs)

Private Sub radiobuttonlist1_selectedvaluechanged(ByVal sender As Object,
ByVal e As System.EventArgs) _
Handles RadioButtonList1.SelectedValueChanged
RaiseEvent selectedvaluechanged(sender, e)
End Sub

....

Code in form hosting the control
Private Sub RadioPanel1_SelectedValueChanged(ByVal sender As Object, ByVal e
As System.EventArgs) _
Handles RadioPanel1.selectedvaluechanged

If RadioPanel1.RadioButtonList1.SelectedIndex > -1 Then
Console.WriteLine(" --> {0}",
RadioPanel1.RadioButtonList1.SelectedValue.ToString)
End If
End Sub


.


Quantcast