Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5963299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:13:49+00:00 2026-05-22T19:13:49+00:00

I’m working with an application that utilizes the Google Weather API, right now I

  • 0

I’m working with an application that utilizes the Google Weather API, right now I got some real ugly code just to populate the 3 day forecast, which looks like so (remember no laughing)

groupBox3.Text = set.Forecast[1].DayOfTheWeek;
label4.Text = string.Format("High {0}", set.Forecast[1].High);
label3.Text = string.Format("Low: {0}", set.Forecast[1].Low);
label11.Text = string.Format("Condition: {0}", set.Forecast[1].Condition);
pictureBox1.Load(set.Forecast[1].Icon);

groupBox4.Text = set.Forecast[2].DayOfTheWeek;
label14.Text = string.Format("High {0}", set.Forecast[2].High);
label13.Text = string.Format("Low: {0}", set.Forecast[2].Low);
label20.Text = string.Format("Condition: {0}", set.Forecast[2].Condition);
pictureBox2.Load(set.Forecast[2].Icon);

groupBox5.Text = set.Forecast[3].DayOfTheWeek;
label7.Text = string.Format("High {0}", set.Forecast[3].High);
label6.Text = string.Format("Low: {0}", set.Forecast[3].Low);
label11.Text = string.Format("Condition: {0}", set.Forecast[3].Condition);
pictureBox3.Load(set.Forecast[3].Icon);

I told you it was ugly. What I would like to do is have a single loop (and possible Generics) to accomplish the same task as this ugly code. I’ve tried a couple different ways but they always fail. The weather is being generated like so

WeatherSet set = WeatherService.Response(GoogleWeatherRequest.RequestData(new WeatherService("99109")));

And inside the variable set there is information for current information and 3 day forecast, but having it run like this drives me insane because it so noobish and not very efficient. So anyone got any cool & efficient way toaccomplish this task?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:13:49+00:00Added an answer on May 22, 2026 at 7:13 pm

    I think you should create your own custom control ForecastView for that with groupbox, three labels and picturebox on it. Let it have a property named Forecast and put the logic that fills the fields inside its setter. That way the code of the form will be really clean, like

    forecastView1.ForeCast = set.Forecast[1];
    forecastView2.ForeCast = set.Forecast[2];
    // etc
    

    Seeing as you are already putting your field inside of the groupbox, placement shouldn’t be a problem.

    Also, putting it all in separate control will give you a lot of code reuse options if one day you need to present this data on another form or even in another app. Not to mention that you’ll be able to change the appearance of all forecasts at once if you decide to put the pictureBox left instead of right, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.