コード例 #1
0
        private void cvState_Validating(object sender, Genghis.Windows.Forms.CustomValidator.ValidationCancelEventArgs e)
        {
            var states = ZoneGenerator.GenerateStateIDsByCountry(address.Data.Country);

            var stateFound = states.FirstOrDefault(c => c.TrimEnd() == cboState.Text.TrimEnd());

            e.Valid = stateFound != null;
        }
コード例 #2
0
        private void cboState_Leave(object sender, EventArgs e)
        {
            var index = ZoneGenerator.GenerateStateIDsByCountry(address.Data.Country).FindIndex(c => c.TrimEnd() == cboState.Text.TrimEnd().ToUpper());

            if (index != -1)
            {
                cboState.SelectedIndex = index + 1;
                cvState.Validate();
            }
        }
コード例 #3
0
        private void PopulateStateComboBox()
        {
            UnsubscribeToStateChanged();

            var states = ZoneGenerator.GenerateStateIDsByCountry(address.Data.Country);

            cboState.Items.Clear();
            states.ForEach(c => cboState.Items.Add(c));
            cboState.Items.Insert(0, "");

            SubscribeToStateChanged();
        }
コード例 #4
0
        private void PopulateCountryComboBox()
        {
            UnsubscribeToStateChanged();

            countryNames = countryNames ?? ZoneGenerator.GenerateCountryIDs();
            if (cboCountry.Items.Count == 0)
            {
                cboCountry.DataSource = countryNames;
            }

            SubscribeToStateChanged();
        }
コード例 #5
0
        private void SetState()
        {
            var states = ZoneGenerator.GenerateStateIDsByCountry(address.Data.Country);
            var index  = states.FindIndex(c => c.TrimEnd() == address.Data.State);

            if (index != -1)
            {
                cboState.SelectedIndex = index + 1; //make up for empty option
            }
            else
            {
                cboState.SelectedIndex = 0;
            }
        }
コード例 #6
0
        private void SelectCountry()
        {
            countryNames = countryNames ?? ZoneGenerator.GenerateCountryIDs();

            if (cboCountry.Items.Count == 0)
            {
                cboCountry.DataSource = countryNames;
            }

            var index = countryNames.FindIndex(c => c.Contains(address.Data.Country));

            if (index != -1)
            {
                cboCountry.SelectedIndex = index;
            }
            else
            {
                cboCountry.Text = address.Data.Country;
            }
        }