private void cbCountry_Leave(object sender, EventArgs e)
        {
            DynamicCombo comboBox = sender as DynamicCombo;

            //cbCountry_SelectionChangeCommitted(comboBox, null);
            comboBox.Close();
        }
        public void newRefresh <T>(DynamicCombo comboBox, IEnumerable <T> list)
        {
            var tempList = list.Select(item => item).ToList();

            if (tempList.Count > 0)
            {
                string tempString = comboBox.Text;
                comboBox.DataSource    = tempList;
                comboBox.SelectedIndex = -1;
                comboBox.Text          = tempString;

                int listLength;
                if (comboBox.Items.Count > 10)
                {
                    listLength = 10;
                }
                else
                {
                    listLength = comboBox.Items.Count;
                }

                comboBox.Height = comboBox.ItemHeight * listLength + comboBox.ItemHeight * 2;

                Cursor.Current = DefaultCursor;
            }
            else
            {
                comboBox.DataSource = tempList;
                comboBox.Close();
            }
            comboBox.SelectionStart = comboBox.Text.Length + 1;
        }
        private void cbCountry_TextUpdate(object sender, EventArgs e)
        {
            DynamicCombo comboBox = sender as DynamicCombo;
            var          list     = CountryList.Where(country => country.Name.StartsWith(comboBox.Text, true, ci));

            newRefresh <Country>(comboBox, list);
        }
        private void cbCity_TextUpdate(object sender, EventArgs e)
        {
            DynamicCombo comboBox = sender as DynamicCombo;

            cityList = Connection.TripperData.Localizations.Where(city => city.Country.Equals(cbCountry.SelectedItem)).ToList();
            var citesByCountry = cityList.Where(city => city.City.StartsWith(comboBox.Text, true, ci)).ToList();

            newRefresh <Localization>(comboBox, citesByCountry);
        }
        public void drawWarningBoeder(object sender)
        {
            DynamicCombo comboBox = sender as DynamicCombo;

            Graphics g = this.CreateGraphics();

            Pen blackPen = new Pen(Color.Firebrick, 2);
            int x        = comboBox.Location.X;
            int y        = comboBox.Location.Y;
            int width    = comboBox.Width;
            int height   = comboBox.Height;

            g.DrawRectangle(blackPen, x, y, width, height);
            blackPen.Dispose();
        }
        private void cbCountry_SelectionChangeCommitted(object sender, EventArgs e)
        {
            DynamicCombo comboBox = sender as DynamicCombo;

            cityList          = Connection.TripperData.Localizations.Where(city => city.Country.Equals(cbCountry.SelectedItem)).ToList();
            cbCity.DataSource = cityList;

            SelectedLocalization = null;
            cbCity.Text          = "";

            checkCountryValidation(false);
            if (SelectedLocalization == null)
            {
                cbCity.SelectedIndex = -1;
            }
        }