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
close icon

Getting selected values for multi selections and highlighted selected in list

Hi,

I would like to know how do I get the list of selected values from combo box with multi selection enabled

Also, I would like to find out how do I indicate/hide items that have already been selected from the list. (list of items can be in checkbox style)

XAML Code

CS code


I am looking to have something similar like below


9 Replies

HM Hemalatha Marikumar Syncfusion Team January 23, 2020 12:44 PM UTC

Hi Benjamin, 
 
Greetings from Syncfusion. 
 
We would like to let you know that currently we don’t have a direct support to have checkbox in ComboBox’s suggestion box. We have considered this as feature and logged this as a feature request, and you can track the status of this feature implement through below link  
  
 
Please cast your vote to make it count. We will prioritize the features every release based on the demands and we do not have an immediate plan to implement this feature since we committed with already planned work. So, this feature will be available in any of our upcoming releases.      
    
If you have any more specifications/suggestions to the feature request, you can add it as a comment in the portal. 
 
Regards, 
Hemalatha M. 



BE Benjamin January 23, 2020 02:04 PM UTC

Hi

Thanks for the reply. In that case, while waiting for the feature to get implement, how do i highlight the selected item. And how do i get the selected item?


HM Hemalatha Marikumar Syncfusion Team January 24, 2020 10:16 AM UTC

Hi Benjamin, 
 
Query: How do I highlight the selected item 
 
It is possible to highlight the selected item like showing the indicator as per in below attached image. It has been achieved by enabling the EnableSelectionIndicator with providing the desired icon text (now providing the tick icon with its font family) as per in below code snippet 
 
Code Snippet [XAML]: 
<combobox:SfComboBox HeightRequest="40"  
                             x:Name="comboBox" 
                             EnableSelectionIndicator="True" 
                             MultiSelectMode="Token" 
                             IndicatorTextColor="Red" 
                             IndicatorFontFamily="{StaticResource BoldFont}" 
                             IndicatorText="&#xE73E;"> 
             <combobox:SfComboBox.TokenSettings> 
                   .. 
            </combobox:SfComboBox.TokenSettings> 
            <combobox:SfComboBox.ComboBoxSource> 
                <ListCollection:List x:TypeArguments="x:String"> 
                    <x:String>France</x:String> 
                       
                </ListCollection:List> 
            </combobox:SfComboBox.ComboBoxSource> 
        </combobox:SfComboBox> 
 
 
Screenshot
 
 
 
Query: How do I get the selected item? 
 
SelectedItem property to get the selected items from ComboBox. Please refer the below UG link to find the way to retrieve the selected item in more detailed 
 
 
Please let us know if you have any other concerns. 
  
Regards, 
Hemalatha M. 



BE Benjamin January 29, 2020 09:21 AM UTC

Hi, I realized another issue that if I click on the selected item again, it will get selected again. refer to the attached image.



how do I fix this? I am looking for something like when the item was first clicked on it will be selected, if user click again it will be unselected.

i tried using the selecteditem property to get the selected items of the combo box but i received this instead
System.Collections.ObjectModel.ObservableCollection`1[System.Object]

i also tried foreach(var item in comboBox.SelectedItem), but visual studio prompted that

foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public instance definition for 'GetEnumerator'



HM Hemalatha Marikumar Syncfusion Team January 29, 2020 01:14 PM UTC

Hi Benjamin, 
  
Query 1: Clicking on the selected item again, gets selected. 
 
We have used SelectionIndicator just to showcase the item is selected. Please ensure whether you have added the ttf file properly to resolve the icon display. The SelectedItem will be selected again if you select it. That's the behavior of the control. 
 
Query 2Removing SelectedItem 
 
It is possible to remove the SelectedItem from the drop-down suggestion list by enabling the IsSelectedItemsVisibleInDropDown to false. 
 
If you want to check and uncheck the items, please followup this feature implemention as we updated earlier, we will implement this in our any of upcoming release. 
 
 
Regards, 
Hemalatha M. 



BE Benjamin January 30, 2020 07:16 AM UTC

Hi thanks for the reply,

would like to check how do i get the list of selected items in the multi-selected combo box?

i tried using the selecteditem property to get the selected items of the combo box but i received this instead
System.Collections.ObjectModel.ObservableCollection`1[System.Object]

i also tried foreach(var item in comboBox.SelectedItem), but visual studio prompted that

foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public instance definition for 'GetEnumerator'


HM Hemalatha Marikumar Syncfusion Team January 31, 2020 12:15 PM UTC

Hi Benjamin, 
  
We would like to let you know that we checked the reported query and we suggest you to retrieve the selected items in MultiSelection mode as per in below code snippet: 
 
private void ComboBox_SelectionChanged(object sender, Syncfusion.XForms.ComboBox.SelectionChangedEventArgs e) 
        { 
            ObservableCollection<object> item = new ObservableCollection<object> { e.Value }; 
        } 
 
 
 
Regards, 
Hemalatha M. 



BE Benjamin January 31, 2020 02:15 PM UTC

Hi Hemalatha,

Thanks for the reply. would like to double check if i need to process the selected items after user submit the form, i will proceess using the ObservableCollection<object> item.

Something like 

List<string>selectedItems = new List<string>();
foreach(var o in item)
selectedItems.Add(o.Value);


HM Hemalatha Marikumar Syncfusion Team February 3, 2020 11:13 AM UTC

Hi Benjamin, 
  
We would like to let you know that we checked the provided code snippet and we suggest you to use List<object> instead of List<string> because the SelectedItem will return only the object. Please find the tested sample below:   
 
 
Regards, 
Hemalatha M. 


Loader.
Live Chat Icon For mobile
Up arrow icon