예제 #1
0
        private void LoadStateComboBox()
        {
            List <State> states = new List <State>();

            try
            {
                states = StateDB.GetStates();
                cboStates.DataSource    = states;
                cboStates.DisplayMember = "StateName";
                cboStates.ValueMember   = "StateCode";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }
예제 #2
0
        private void LoadStateComboBox()
        {
            // create new List of States
            List <State> states = new List <State>();

            try
            {
                // get states from the state database
                states = StateDB.GetStates();
                cboStates.DataSource = states;
                // what you want the user to see: state name
                cboStates.DisplayMember = "StateName";
                // what field you want in the database: state code
                cboStates.ValueMember = "StateCode";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }