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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How To Get All Selected Value in MultiSelectComboBox

Thread ID:

Created:

Updated:

Platform:

Replies:

119991 Aug 20,2015 03:35 PM UTC May 4,2017 09:13 AM UTC WinForms 5
loading
Tags: MultiSelectionComboBox
Indra
Asked On August 20, 2015 03:35 PM UTC

Dear All,

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

Thanks

Senthil Kumaran Rajan [Syncfusion]
Replied On 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 : http://www.syncfusion.com/downloads/support/forum/119991/ze/MultiSelectSelectedValue229948667

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

Please let us know if you need further assistance.

Regards,
Senthil

Thomas Pagram
Replied On 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


Keerthana Jegannathan [Syncfusion]
Replied On 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 


Felix Bagur
Replied On 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

                 


Vinothini [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;