We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How To Get All Selected Value in MultiSelectComboBox

Dear All,

Help, How can I  get all selected value that i checked in MultiSelectComboBox.

Thanks

5 Replies

SK Senthil Kumaran Rajan Syncfusion Team August 21, 2015 09:45 AM UTC

Hi Indra,

Thank you for using Syncfusion products.

This reported requirement can be achieved by using SelectedItems property in MultiSelectionComboBox. Please make use below code example for your reference.

Code Snippet[C#]:

//To get the added Visual items in MultiSelectionComboBox

this.multiSelectionComboBox1.VisualItems


//To get the selected items in MultiSelectionComboBox

this.multiSelectionComboBox1.SelectedItems



We have also prepared a sample and video for your reference which can be downloaded from the below location.

Sample Location : https://www.syncfusion.com/downloads/support/forum/119991/ze/MultiSelectSelectedValue229948667

Video Location ; https://www.syncfusion.com/downloads/support/forum/119991/ze/MultiSelection1192145006

Please let us know if you need further assistance.

Regards,
Senthil


TP Thomas Pagram May 9, 2016 12:02 PM UTC

Hi Senthil,

This code seems to retrieve displaymembers rather than value members. How can I retrieve a list/array of all selected values:

this.multiSelectionComboBox1.SelectedItems


Thanks

Thomas



KJ Keerthana Jegannathan Syncfusion Team May 10, 2016 12:01 PM UTC

Hi Thomas.   
   
Thank you for your update.   
   
If you want to retrieve Selected Items collection for Value Member type in MultiSelectionComboBox, then we are sorry to say that at present there is no support for this reported requirement in MultiSelectionComboBox. Hence, we have prepared Custom MultiSelectionComboBox inherited from MultiSelectionComboBox.    
   
Steps Followed   
   
1)      Created custom control inherited from MultiSelectionComboBox.   
2)      Implemented property named SelectedValues collection that holds Selected Value collection.    
3)      Updated SelectedValue collection, by handling events named “CheckChanged” and “ControlRemoved”.   
   
Please make use of the below code snippet for your reference.    
 
Code Snippet: [C#] 
 
 
// Custom control to display ValueMember  
public class MultiSelectionComboBoxExt : MultiSelectionComboBox  
  
//To remove the selected values if it has been unchecked  
void MultiSelectionComboBoxExt_ControlRemoved(object sender, System.Windows.Forms.ControlEventArgs e)  
 
     for (int i = 0; i <= this.SelectedValues.Count - 1; i++)  
     {  
        if (this.SelectedValues[i].DisplayMember == e.Control.Text)  
        {  
             this.SelectedValues.RemoveAt(i);  
             break 
        }  
     }  
 
  
// To add value members of the selected values into the collection when it is checked  
void MultiSelectionComboBoxExt_CheckChanged(object sender, CheckedStateEventArgs 
 
      if (e.Checked)  
      {  
       this.SelectedValues.Add(new DataCollection(this.SelectedItems[this.SelectedItems.Count - 1].ToString(), e.Item.ToString()));  
      }  
 
 
 
We have prepared sample for your reference which can be downloaded from the below location. 
 
 
 
We have prepared a video, which can be downloaded from the below location.   
 
 
Screenshot 
 
 
 
 
Regards, 
Keerthana 



FB Felix Bagur May 3, 2017 03:53 PM UTC

Hello,

Another way to get the selected values assuming you use a datatable with two columns pk and value (for example) would be the following:

 Public Function getSelectedKeys() As List(Of String)

      Dim pks As New List(Of String)()

        For i As Integer = 0 To Me.SelectedItems.Count - 1

              Dim dr As DataRow = CType(Me.DataSource, DataTable).Select("value = '" & SelectedItems(i) & "'").SingleOrDefault

              pks.Add(dr("pk"))

         Next i

   Return pks

 End Function

                 



VI Vinothini Syncfusion Team May 4, 2017 09:13 AM UTC

Hi Felix, 
 
Thank you for defining us another method for getting the selected values list in MultiselectionComboBox using Linq . But in order to support all .Net Framework version, we have given the workaround in MultiSelectionComboBox control. 
 
Please let us know if you need any assistance on this. 
 
Regards, 
Vinothini.R 


Loader.
Live Chat Icon For mobile
Up arrow icon