示例#1
0
        private void ReadWeatherAPIAndBindToDataGrid()
        {
            //
            // read data file
            //
            IDataService dataService = new APIDataService();

            _cities = dataService.ReadAll();

            //
            // bind list to DataGridView control
            //
            var bindingList = new BindingList <City>(_cities);
            var source      = new BindingSource(bindingList, null);

            dataGridViewCities.DataSource = source;

            //
            // configure DataGridView control
            //
            this.dataGridViewCities.Columns["Pressure"].Visible = false;
            this.dataGridViewCities.Columns["Humidity"].Visible = false;
            this.dataGridViewCities.Columns["Deg"].Visible      = false;
            this.dataGridViewCities.Columns["Icon"].Visible     = false;
        }
        private void ReadWeatherAPIAndBindToDataGrid()
        {
            //
            // read data file
            //
            IDataService dataService = new APIDataService();

            _cities = dataService.ReadAll();

            //
            // bind list to DataGridView control
            //
            var bindingList = new BindingList <City>(_cities);

            dataGridViewCities.ItemsSource = bindingList;

            dataGridViewCities.Columns["Pressure"].Width      = 0;
            this.dataGridViewCities.Columns["Humidity"].Width = 0;
            this.dataGridViewCities.Columns["Deg"].Width      = 0;
            this.dataGridViewCities.Columns["Icon"].Width     = 0;

            lbl_results.Content = $"Records Returned({bindingList.Count})";
        }