问题描述
//now i want the label in this method to be displayed when a button is clicked in the second form
public void display()
{
cityVar = cities;
dateVar = Date;
min_TempVar = MinTemp;
maxTempVar = MaxTemp;
precipitationVar = precipitation;
humidityVar = humidity;
windSpeedVar = Wind;
// ReportForm rf = new ReportForm(); i am calling the second form
// rf.Display_Label.Text is a label in the Report form
rf.Display_Label.Text = string.Format(@"
Weather forecast for {0}
for the {1}
------------------------------------------
min temp: {2} C
max temp: {3} C
precipitation: {4} %
humidity: {5} %
wind speed:{6} km/h ",
cityVar, dateVar, min_TempVar, maxTempVar, precipitationVar,
humidityVar,windSpeedVar);
}
//this how i did it but it does not seem to work , can someone please assist me in the correct way to do this
private void button1_Click(object sender, EventArgs e)
{
// WeatherApp form = new WeatherApp(); calls the first form
WeatherApp form = new WeatherApp();
// form.display() should call the Public void display method which is in the WeatherApp form
form.display();
}
标签: c#
解决方案
推荐阅读