Articles in this section
Category / Section

How to set the SelectedItem in SfcomboBox in Xamarin.iOS

1 min read

You can set the SelectedValue in SfcomboBox in Xamarin.iOS by setting a value to the SelectedItem property.

 

Step 1: Add the SfCombobox control and add the items using the data source property.

Step 2: Add the UIButton and add the click event to the UI button.

Step 3: In the button click event, set the value to the selected item property.

 

The following code demonstrates how to navigate between the tab items using tap gesture.

 

C#

public partial class MyViewController : UIViewController
    {
        ObservableCollection<Employee> EmployeeDetails;
        SfComboBox combobox;
        public MyViewController() : base("MyViewController", null)
        {
            combobox = new SfComboBox(); 
            combobox.IsEditable = true; 
            combobox.SuggestionMode = SuggestionMode.StartsWith; 
            combobox.Frame = new CoreGraphics.CGRect(25,100, UIScreen.MainScreen.Bounds.Width-50, 40);
            combobox.ItemHeight = 60; 
            this.GetEmployeeData(); 
            combobox.DisplayMemberPath = (NSString)"Condition";
            combobox.SelectedValuePath = (NSString)"ConditionId";
            combobox.DataSource = EmployeeDetails; 
            combobox.MaxDropDownHeight = 250;
            UIButton uIButton = new UIButton();
            uIButton.BackgroundColor = UIColor.LightGray;
            uIButton.SetTitle("Set SelectedItem", UIControlState.Normal);
            uIButton.Frame = new CoreGraphics.CGRect(25,300, UIScreen.MainScreen.Bounds.Width-50, 60); 
            uIButton.TouchUpInside += UIButton_TouchUpInside;
            this.Add(combobox);
            this.Add(uIButton);
        }
        void UIButton_TouchUpInside(object sender, EventArgs e)
        {
            combobox.SelectedItem = EmployeeDetails[4];
        }

 

 

Please download the sample from the following link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfCombobox211608-1535692654

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied