Xamarin.iOS Documentation | ComponentOne
Controls / Input / ComboBox / Quick Start: Display a C1ComboBox Control
In This Topic
    Quick Start: Display a C1ComboBox Control
    In This Topic

    This section describes adding a C1ComboBox control to your iOS application and displaying a list of items in the drop-down as input suggestions for users.

    Complete the following steps to display a C1ComboBox control.

    The following image shows a C1ComboBox displaying input suggestions as the user types.

    Xuni's ComboBox control

    Step 1: Create a data source

    Add a new class to the application that serves as the data source for C1AutoComplete.

    C#
    Copy Code
    class Countries : NSObject
    {
        [Export("Name")]
        public string Name { get; set; }
    
        public Countries()
        {
            this.Name = string.Empty;
        }
    
        public Countries(string name)
        {
            this.Name = name;
        }
    
        public static IEnumerable<object> GetDemoDataList()
        {
            List<object> array = new List<object>();
            var quarterNames = "Australia,Bangladesh,Brazil,Canada,China".Split(',');
    
            for (int i = 0; i < quarterNames.Length; i++)
            {
                array.Add(new Countries
                {
                    Name = quarterNames[i]
                });
            }
            return array as IEnumerable<object>;
        }
    }
    

    Back to Top

    Step 2: Add a C1ComboBox control to ViewController

    1. Initialize a C1ComboBox control in the ViewDidLoad method.
      C#
      Copy Code
      public override void ViewDidLoad()
      {
          base.ViewDidLoad();
      
          ComboBoxEdit.DisplayMemberPath = "Name";
          ComboBoxEdit.ItemsSource = Countries.GetDemoDataList();
          ComboBoxEdit.DropDownHeight = 200;
          ComboBoxEdit.Placeholder = "Please Enter...";          
      }
      

    Step 3: Run the Project

    Press F5 to run the application.