怎么用C#写天气预报  我要的是黑色背景  我网上找了很多 都是白色的 

解决方案 »

  1.   

    socket+HTTP协议 到其它天气预报网站抓取天气信息,然后处理、显示
      

  2.   

    Web Services,
    http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx
    用法去网上搜索Web Services使用。
      

  3.   

    可以用黑色啊,在iframe里用属性allowTransparency,例如:
    <iframe id="weather" src="http://m.weather.com.cn/m/pn1/weather.htm" frameborder="0" scrolling="no" allowTransparency="true"
    ></iframe>
    以上设置iframe为透明,然后在对应的css中写上:background:black;
      

  4.   

    使用webServer,要黑色自己设背景
      

  5.   

    http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx
    这里没有找不到类啊  难道他里面都是静态方法吗 
      

  6.   

    一般都是使用WebService获取天气信息
      

  7.   

    怎么引用别的网站的webservice啊,比方说银行,网银,天气预报之类的。
      

  8.   

    添加别人的webservice引用,调用对应的函数获取信息,你看看webservice的使用方法
      

  9.   

    MessageBox.Show("今天阴转多云、有时有雨");
      

  10.   

    找格web service  获得数据  
    你自己写个网页  
    背景色设置为 黑色
      

  11.   

    如果只是加到网站上的某个角落,加一个iframe就可以,背景也是可以设置的
      

  12.   

    看看这段代码,或许对你有帮助
    namespace 天气预报程序
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void btntj_Click(object sender, EventArgs e)
            {
                if (txtcity.Text != "")
                {
                    lblts.Text = "正在读取中...";
                    pl1.Visible = false;
                    lblts.Visible = true;
                    btntj.Enabled = false;
                    txtname.Text = "";
                    web.Url = new System.Uri("http://weather.tq121.com.cn/detail.php?city=" + txtcity.Text, System.UriKind.Absolute);
                }
                else
                {
                    MessageBox.Show("请先输入城市名称");
                }
            }
            public string dz(string dz)
            {            return "http://weather.tq121.com.cn" + Regex.Replace(dz, "\\.\\.", "");
            }
            public string ht(string dz)
            {
                dz = Regex.Replace(dz, "b", "a");
                dz=Regex.Replace(dz, "\\.\\.", "");            return "http://weather.tq121.com.cn" + dz;
            }
            public string gl(string gl)
            {
                if (gl.IndexOf("/") == -1)
                {
                    gl = Regex.Replace(gl, "\\s", "");
                }
                return Regex.Replace(gl, "cn\">", "");
            }
            private void web_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                //初始化WEB源文件
                StreamReader strmrd = new StreamReader(web.DocumentStream, Encoding.GetEncoding("GB2312"));
                string strhtml = strmrd.ReadToEnd();
                if (strhtml.IndexOf("问天网") == -1)
                {
                    lblts.Text = "查询失败,请检查网络。"; 
                    btntj.Enabled = true;
                }
                else if(strhtml.IndexOf("城市不存在")!= -1)
                {
                    lblts.Text = "您输入的城市不存在。";
                    btntj.Enabled = true;
                }
                else
                {
                    int start, end;
                    //关闭显示的提示文字
                    pl1.Visible = true;
                    lblts.Visible = false;
                    //获取城市的省份
                    start = strhtml.IndexOf("<td width=\"222\" class=\"big-cn\">");
                    end = strhtml.IndexOf("&gt;");
                    txtname.Text = strhtml.Substring(start + 31, (end - 1) - (start + 31));
                    //获取近3天的标签
                    string[] rqbq ={ "0", "0", "0", "0", "0", "0", "0", "0", "0" };
                    start = end = 0;
                    for (int j = 0; j < 9; j++)
                    {
                        start = strhtml.IndexOf("<td width=\"215\" align=\"center\" valign=\"middle\"><span ", start + 1);
                        end = strhtml.IndexOf("</span></td>", start);
                        rqbq[j] = strhtml.Substring(start + 64, end - (start + 64));
                    }
                    lbl1.Text = gl(rqbq[0]);
                    wd1.Text = gl(rqbq[1]);
                    zt1.Text = gl(rqbq[2]);
                    lbl2.Text = gl(rqbq[3]);
                    wd2.Text = gl(rqbq[4]);
                    zt2.Text = gl(rqbq[5]);
                    lbl3.Text = gl(rqbq[6]);
                    wd3.Text = gl(rqbq[7]);
                    zt3.Text = gl(rqbq[8]);
                    //获取天气图标
                    start = end = 0;
                    string[] tqtb ={ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" };
                    for (int i = 0; i < 6; i++)
                    {
                        start = strhtml.IndexOf("valign=\"top\"><img src=\"..", start + 1);
                        end = strhtml.IndexOf("\" width=\"70\" height=\"65\"></td>", start);//54           
                        tqtb[i] = dz(strhtml.Substring(start + 25, end - (start + 25)));
                    }
                    pic1.ImageLocation = tqtb[0];
                    pic2.ImageLocation = tqtb[1];
                    pic3.ImageLocation = tqtb[2];
                    pic4.ImageLocation = tqtb[3];
                    pic5.ImageLocation = tqtb[4];
                    pic6.ImageLocation = tqtb[5];
                    //获取后两天日期
                    start = end = 0;
                    string[] hriqi ={ "0", "0" };
                    for (int k = 0; k < 2; k++)
                    {
                        start = strhtml.IndexOf("<td width=\"121\"><span class=\"cn\">", start + 1);
                        end = strhtml.IndexOf("</span></td>", start);//33         
                        hriqi[k] = strhtml.Substring(start + 33, end - (start + 33));
                    }
                    lbl4.Text = hriqi[0];
                    lbl5.Text = hriqi[1];
                    //获取后两天状态                start = end = 0;
                    string[] hzt ={ "0", "0" };
                    for (int k = 0; k < 2; k++)
                    {
                        start = strhtml.IndexOf("<td width=\"157\"><span class=\"cn\">", start + 1);
                        end = strhtml.IndexOf("</span></td>", start);//33         
                        hzt[k] = strhtml.Substring(start + 33, end - (start + 33));
                    }
                    zt4.Text = hzt[0];
                    zt5.Text = hzt[1];
                    //获取后两天温度                start = end = 0;
                    string[] hwd ={ "0", "0" };
                    for (int k = 0; k < 2; k++)
                    {
                        start = strhtml.IndexOf("<td width=\"86\" class=\"cn\"><span class=\"wendu\">", start + 1);
                        end = strhtml.IndexOf("</span></td>", start);//46        
                        hwd[k] = strhtml.Substring(start + 46, end - (start + 46));
                    }
                    wd4.Text = gl(hwd[0]);
                    wd5.Text = gl(hwd[1]);
                    //获取后两天图标                start = end = 0;
                    string[] htbs ={ "0", "0", "0", "0" };
                    for (int k = 0; k < 2; k++)
                    {
                        start = strhtml.IndexOf("<td width=\"59\"><img src=\"", start + 1);
                        end = strhtml.IndexOf("\" width=\"50\"", start);//38       
                        htbs[k] = strhtml.Substring(start + 25, end - (start + 25));
                    }
                    start = end = 0;
                    for (int k = 2; k < 4; k++)
                    {
                        start = strhtml.IndexOf("<td width=\"64\" align=\"left\"><img src=\"", start + 1);
                        end = strhtml.IndexOf("\" width=\"50\"", start);//38       
                        htbs[k] = strhtml.Substring(start + 38, end - (start + 38));
                    }
                    pic7.ImageLocation = ht(htbs[0]);
                    pic9.ImageLocation = ht(htbs[1]);
                    pic8.ImageLocation = ht(htbs[2]);
                    pic10.ImageLocation = ht(htbs[3]);
                    btntj.Enabled = true;
                }
             }        private void txtcity_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    btntj_Click(null, null); 
                }
            }
        }
    }
      

  13.   

    http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx
    这里没有找不到类啊 难道他里面都是静态方法吗 
    怎么调用里面的方法
      

  14.   

    网页里试试这个
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <table width="775" height="497" border="0">
      <tr>
        <td><IFRAME id="tianqi8_wetherinfo" name="tianqi8_wetherinfo" src="http://www.uuuu.cc/weather/code/freeweather7.htm?id=&fcolor=ffffff&imgurl=tb/tbb/tb1&bimg=&bcolor=000000&fsize=" frameBorder=0 width=140 height=60 ALIGN=CENTER MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 SCROLLING=NO allowtransparency=true></IFRAME></td>
      </tr>
    </table>
    </body>
    </html>
      

  15.   

    有专门的提供天气信息的web服务,添加一个web引用就可以得到天气信息了,具体web服务名称什么我也忘了,你到网上找一下提供天气信息的web服务吧。
      

  16.   

    哥们啊,人家的Web Service 你直接调来用就行了