/// <summary>
        /// Event listening the user to change the index of the list box. When triggered it shall
        /// populate the fields and disable the fields from user control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LBox_Countries_SelectedIndexChanged(object sender, EventArgs e)
        {
            Country selectedCountry = countries.Get(LBox_Countries.SelectedItem.ToString());

            populateFields(selectedCountry);

            enableFields(false);
        }
Beispiel #2
0
        /// <summary>
        /// When the user adds or remove text from the text box refresh the grid with the
        /// countries that partially match the supplied search name.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TBox_Search_TextChanged(object sender, EventArgs e)
        {
            DGridView_Countries.DataSource = null;
            dataTable.Rows.Clear();
            String partial = TBox_Search.Text;

            foreach (String name in countries.GetPartials(partial))
            {
                Country country = countries.Get(name);
                dataTable.Rows.Add(new Object[] { country.Name, country.GDP,
                                                  country.Inflation, country.TradeBalance, country.HDI,
                                                  String.Join(", ", country.TradePartners) });
            }
            DGridView_Countries.DataSource = dataTable;
        }
Beispiel #3
0
 /// <summary>
 /// When the user clicks the search button attempt to locate all countries that trade
 /// with the provided name.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btn_Search_Click(object sender, EventArgs e)
 {
     DGridView_Countries.DataSource = null;
     dataTable.Rows.Clear();
     if (TBox_Search.Text != "")
     {
         String partner = TBox_Search.Text;
         foreach (String name in countries.GetTradeWith(partner))
         {
             Country country = countries.Get(name);
             dataTable.Rows.Add(new Object[] { country.Name, country.GDP,
                                               country.Inflation, country.TradeBalance, country.HDI,
                                               String.Join(", ", country.TradePartners) });
         }
     }
     DGridView_Countries.DataSource = dataTable;
 }