private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.CurrentCell.ColumnIndex == 1 | dataGridView1.CurrentCell.ColumnIndex == 2 | dataGridView1.CurrentCell.ColumnIndex == 3 | dataGridView1.CurrentCell.ColumnIndex == 4) { return; } user_cities.RemoveAt(dataGridView1.CurrentCell.RowIndex); IProxyWeather proxy = new ProxyWeather(); TotalCDegrees degrees = new TotalCDegrees(); FDegreesConverter converter = new FDegreesConverter(degrees); dataGridView1.Rows.Clear(); foreach (var i in user_cities) { var weather = proxy.Weather(i); converter.ConvertFDegreees(weather.main.temp); double temp = converter.GetCDegrees(); converter.ConvertFDegreees(weather.main.temp_max); double temp_max = converter.GetCDegrees(); converter.ConvertFDegreees(weather.main.temp_min); double temp_min = converter.GetCDegrees(); DisplayCity c = new DisplayCity { Name = i, Temp = temp, TempMax = temp_max, TempMin = temp_min }; datagrid_cities.Add(c); } BindingSource source = new BindingSource(); source.DataSource = datagrid_cities; dataGridView1.DataSource = source; }
private void home_button_Click(object sender, EventArgs e) { IProxyWeather proxy = new ProxyWeather(); TotalCDegrees degrees = new TotalCDegrees(); FDegreesConverter converter = new FDegreesConverter(degrees); dataGridView1.Rows.Clear(); foreach (var i in user_cities) { var weather = proxy.Weather(i); if (weather.main != null) { converter.ConvertFDegreees(weather.main.temp); double temp = converter.GetCDegrees(); converter.ConvertFDegreees(weather.main.temp_max); double temp_max = converter.GetCDegrees(); converter.ConvertFDegreees(weather.main.temp_min); double temp_min = converter.GetCDegrees(); DisplayCity c = new DisplayCity { Name = i, Temp = temp, TempMax = temp_max, TempMin = temp_min }; datagrid_cities.Add(c); } } BindingSource source = new BindingSource(); source.DataSource = datagrid_cities; dataGridView1.DataSource = source; panel_add.Visible = false; panel4.Visible = true; }