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; }
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(); } }
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(); }
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; } }