Exemplo n.º 1
0
        private void OnComboBoxInput_TextChanged(object sender, EventArgs e)
        {
            var input  = _comboBoxInput.Text.Trim();
            var cities = _citiesService.GetCitiesStartsWith(input);

            if (cities.Count > 0)
            {
                _comboBoxInput.DataSource    = cities;
                _comboBoxInput.DisplayMember = nameof(City.Name);
                var sText = _comboBoxInput.Items[0].ToString();
                _comboBoxInput.SelectionStart  = input.Length;
                _comboBoxInput.SelectionLength = sText.Length - input.Length;
                _comboBoxInput.DroppedDown     = true;
            }
            else
            {
                _comboBoxInput.DroppedDown    = false;
                _comboBoxInput.SelectionStart = input.Length;
            }
        }