Listbox - First Item automatically selected

Offsuit9_2

New member
Joined
Mar 29, 2006
Messages
3
Programming Experience
3-5
Having an issue where the first time an item is selected in a listbox the below handler will be triggered, but then right when it is done it will be triggered again with both the initial item and the very first item in the listbox selected. If you then reselect just the item, the problem does not occur. The listbox (as seen below in its initialization) is tied to a dataset. Anyone encounter this? Any ideas? Thanks.
VB.NET:
Expand Collapse Copy
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] StateList_SelectedValueChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] StateList.SelectedValueChanged
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] F_EventsEnabled [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] TabControl.SelectedIndex = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]F_EventsEnabled = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Cursor.Current = Cursors.WaitCursor
RetrieveCounties()
RetrieveHospitals()
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Cursor.Current = Cursors.Arrow
F_EventsEnabled = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE] 
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] RetrieveStates()
FetchData("States", "SELECT State FROM (AP_Account_Entity) GROUP BY State ORDER BY State")
[/SIZE][SIZE=2][COLOR=#008000]' Bind to Tab "Claims" State Control
[/COLOR][/SIZE][SIZE=2]StateList.DataSource = dsResults.Tables("States")
StateList.DisplayMember = "State"
StateList.Refresh()
[/SIZE][SIZE=2][COLOR=#008000]' Bind to Tab "Hospital" State Control
[/COLOR][/SIZE][SIZE=2]Tab2_States.DataSource = dsResults.Tables("States")
Tab2_States.DisplayMember = "State"
Tab2_States.Refresh()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
 
Last edited by a moderator:
Back
Top