G
Guest
Hi
NET1.1 / Winforms
I have a listbox that I am binding to a table via the DataSource property.
However I want to be able to programmatically select values in this listbox
so I am using the code below...
With lstJobTypes
.DataSource = BusinessRules.Common.JobTypes.All(True)
.DisplayMember = "Description"
.ValueMember = "JobTypeID"
End With
If Not _DefaultJobTypes Is Nothing Then
For Each j As PlasmaCommon.JobType In m_DefaultJobTypes
lstJobTypes.SelectedValue = CInt(j)
Next
End If
If I step through using the debugger, I can see the
lstJobTypes.SelectedItems.Count property increasing everytime I set the
SelectedValue and all seems good.
However when the form is then displayed the Count property becomes 1 and
only the first item in the listbox (standard functionality) is selected??!?!?!
The listbox selection mode is set to MultiExtended.
This also happens if I use the SetSelected method rather than the
SelectedValue method.
Any help is greatly appreciated as I am pulling my hair out here
NET1.1 / Winforms
I have a listbox that I am binding to a table via the DataSource property.
However I want to be able to programmatically select values in this listbox
so I am using the code below...
With lstJobTypes
.DataSource = BusinessRules.Common.JobTypes.All(True)
.DisplayMember = "Description"
.ValueMember = "JobTypeID"
End With
If Not _DefaultJobTypes Is Nothing Then
For Each j As PlasmaCommon.JobType In m_DefaultJobTypes
lstJobTypes.SelectedValue = CInt(j)
Next
End If
If I step through using the debugger, I can see the
lstJobTypes.SelectedItems.Count property increasing everytime I set the
SelectedValue and all seems good.
However when the form is then displayed the Count property becomes 1 and
only the first item in the listbox (standard functionality) is selected??!?!?!
The listbox selection mode is set to MultiExtended.
This also happens if I use the SetSelected method rather than the
SelectedValue method.
Any help is greatly appreciated as I am pulling my hair out here