Hi,
I have a combobox that contains four items and it's located on a tab that isn't visible when I show the form. When the tab becomes active the SelectedValueChange event is fired once for each item
When I click on the selected value the event also fires.
This doesn't seem like it's supposed to work?
At least not according to my head
/Kejpa
I have a combobox that contains four items and it's located on a tab that isn't visible when I show the form. When the tab becomes active the SelectedValueChange event is fired once for each item
Code:
'FormLoad....
Dim oTraceList As New ArrayList()
oTraceList.Add(New cComboItem(TraceLevel.Off, "Trace off"))
oTraceList.Add(New cComboItem(TraceLevel.Info, "Info"))
oTraceList.Add(New cComboItem(TraceLevel.Warning, "Warning"))
oTraceList.Add(New cComboItem(TraceLevel.Error, "Error"))
oTraceList.Add(New cComboItem(TraceLevel.Verbose, "Verbose"))
cboTraceLevel.DataSource = oTraceList
cboTraceLevel.DisplayMember = "Display"
cboTraceLevel.ValueMember = "Value"
cboTraceLevel.SelectedIndex = -1
AddHandler cboTraceLevel.SelectedValueChanged, AddressOf cboTraceLevelChanged
cboTraceLevel.SelectedIndex = 0
'FormLoad continues....
Private Sub cboTraceLevelChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Static iSelectedValue As Integer
MsgBox("Old:" & iSelectedValue & vbNewLine & "New:" & cboTraceLevel.SelectedValue)
iSelectedValue = cboTraceLevel.SelectedValue
End Sub
Public Class cComboItem
Private iValue As Long
Private sDisplay As String
Private iImageIndex As Integer = -1
Public Overrides Function ToString() As String
Return sDisplay
End Function
Public Sub New(ByVal Value As Long, ByVal Display As String)
iValue = Value
sDisplay = Display
End Sub
Public ReadOnly Property Value() As Long
Get
Return iValue
End Get
End Property
Public ReadOnly Property Display() As String
Get
Return sDisplay
End Get
End Property
End Class
When I click on the selected value the event also fires.
This doesn't seem like it's supposed to work?
At least not according to my head
/Kejpa