V
Vagabond Software
I'm using VS2003 on .NET 1.1
When I assign a DataSource to my ListBox, the first Item in the Items
collected is automatically selected. I want to avoid this behavior.
I'm halfway to a solution by intercepting the DataSourceChanged event and
de-selecting the Item at the SelectedIndex. This works as desired. There
are no items selected after the DataSource property is changed.
However, the ListBox still shows the first Item as being Highlighted. That
is now misleading because the first Item is, in fact, NOT selected.
Everything operates as desired. The end-user can click on the first Item
and that will select it, but it is misleading that the first Item already
"appears" to be selected because of the Highlight.
Any clues as to how to un-highlight the first Item in a ListBox? Here is
the code used to de-select the first item:
Private Sub lstboxColumns_DataSourceChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles lstboxColumns.DataSourceChanged
If lstboxColumns.SelectedItems.Count > 0 Then
lstboxColumns.SetSelected(lstboxColumns.SelectedIndex, False)
End If
End Sub
Carl
When I assign a DataSource to my ListBox, the first Item in the Items
collected is automatically selected. I want to avoid this behavior.
I'm halfway to a solution by intercepting the DataSourceChanged event and
de-selecting the Item at the SelectedIndex. This works as desired. There
are no items selected after the DataSource property is changed.
However, the ListBox still shows the first Item as being Highlighted. That
is now misleading because the first Item is, in fact, NOT selected.
Everything operates as desired. The end-user can click on the first Item
and that will select it, but it is misleading that the first Item already
"appears" to be selected because of the Highlight.
Any clues as to how to un-highlight the first Item in a ListBox? Here is
the code used to de-select the first item:
Private Sub lstboxColumns_DataSourceChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles lstboxColumns.DataSourceChanged
If lstboxColumns.SelectedItems.Count > 0 Then
lstboxColumns.SetSelected(lstboxColumns.SelectedIndex, False)
End If
End Sub
Carl