WebListBox: Selection Mode Single

Since the WebListBox gives no choice but a multi selection mode, has anyone come up with a subclass that allows single selection mode?

Code like this in the SelectionChanged event will fake it, but since it does a server round-trip there may be a slight pause/delay:

Dim row As Integer = Me.ListIndex For i As Integer = 0 To Me.RowCount-1 If i <> Row Then Me.Selected(i) = False End If Next

I suggest a slight modification:

Dim row As Integer = Me.ListIndex For i As Integer = 0 To Me.RowCount-1 If i <> Row And Me.Selected(i) Then Me.Selected(i) = False End If Next

That way you’re not sending commands to rows that were not selected anyway. It would be even better to keep track of the last selected row and just deselect that one:

If Me.ListIndex<>LastSelectedRow Then Me.Selected(LastSelectedRow) = False LastSelectedRow = Me.ListIndex End If

This does not work for me because when I deselect the previously selected row it fires the SelectionChanged again.

I have tried to set a session variable at the beginning of the SelectionChanged event to detect that a selection event is in progress so the subsequent SelectionChanged event can ignore it but I still get strange results. I think it is due to some timing issues.

Is there any other solution?

Thanks.

I know this is an old topic but i had even a problem with multiple selection to.

i have a listbox where the staff is listed and only 1 line should be edited by cellclick event. On the first entry it was no problem but on every following entry several lines was selected. To prevent from this after my editing routine i simply set the listindex to -1 and so no entry was selected. i hope i can help anyone. Excuse my english :slight_smile: