ListBox multi selection - Why is it missing from the CF?

I have an application that I've ported over from embedded VB to VB.NET under the compact framework and have discovered that I can no longer have a multiple selection listbox.  Why was this functionality taken out   Is there an equivalent functionality with some othe control   I've looked at the ListView but it just doesn't deliver the same simplicity as a multi selection listbox.



Answer this question

ListBox multi selection - Why is it missing from the CF?

  • andy2345

    this peace of code is not working.  if possible give the Detailed one

    Regards
    Sarath

  • yep_its_me

    Okay, I've managed to get a pretty good version of a CheckedListBox control by using the ListView control as a basis.  Here's the class I created.  If you add one  ColumnHeader to this "enhanced" ListView and set the width to the width of the ListView - 16, it comes out looking pretty good.

    clbNew = New cfCheckedListBox

    clbNew.View = View.Details

    clbNew.HeaderStyle = ColumnHeaderStyle.None

    clbNew.CheckBoxes = True

    Public Class cfCheckedListBox

    Inherits System.Windows.Forms.ListView

    Private mMultiSelect As Boolean = False

    Private mSelectedIndex As Integer = -1

    Property MultiSelect() As Boolean

    Get

    MultiSelect = mMultiSelect

    End Get

    Set(ByVal Value As Boolean)

    mMultiSelect = Value

    End Set

    End Property

    Property SelectedIndex() As Integer

    Get

    SelectedIndex = mSelectedIndex

    End Get

    Set(ByVal Value As Integer)

    mSelectedIndex = Value

    End Set

    End Property

    Private Sub CheckedListBox_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles MyBase.ItemCheck

    If Not Me.MultiSelect Then

    If e.NewValue = CheckState.Checked Then

    If Me.SelectedIndex <> -1 Then

    Me.Items.Item(Me.SelectedIndex).Checked = False

    End If

    Me.SelectedIndex = e.Index

    Me.Items.Item(e.Index).Selected = True

    End If

    End If

    End Sub

    End Class


  • CanGIS

    One way to get similiar functionality with multiple selection support is to use ListView control.If you set the View property of the ListView to List you will get a ListBox alike look and feel. You may use  SelectedIndicies property to get the indicies of the selected items.

    Ruslan
    blog: http://xman892.blogspot.com



  • Daigo Hamura

    Sort of yes, sort of no...

    To get multiple selection capability you need to have the CheckBoxes property set to True, which wouldn't be all that bad if it worked like a Checked ListBox in the larger Framework.  When you tap on an item in the ListView it only highlights the text of the item and not the white space to the right of it in the way that a ListBox does.  Coming from a ListBox that had multiple selection capability to a ListView is sort of a step down in application appearance.

  • laughing gnome

    I'm working ListViews in Compact Framework 2, but cant get multi-selection working. I have checkboxes set to 'true' and view property as 'list'. Is it simply not supported

  • Leo Lucas

    Yes it looks great, but I can't get the list of selected items out of it :)
  • ListBox multi selection - Why is it missing from the CF?