如何使用C#在智能设备中使用Webrowser [英] How to work with webrowser in Smart device using C#

查看:73
本文介绍了如何使用C#在智能设备中使用Webrowser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我使用C#在智能设备中开发了gps应用程序,因为我正在获取GPS数据,因此可以在不同的文本框中将GPS数据转换为纬度和经度.

当我尝试使用此经度和纬度在地图中定位位置时,我使用了网络浏览器,但由于未在地图中定位当前位置而出现错误.

请发送解决方案
我也在发送错误:

Hi friends
I developed gps application in smart device using C#, in that i am getting the GPS data i converted GPS data into latitude and longitude in different text box for this no problem.

when i trying to locate position in the map using this latitude and longitude for this i used web browser it give errors it not locating the present position in the map.

please send the solution
i am sending errors also:

Error   1   The best overloaded method match for 'System.Windows.Forms.WebBrowser.Navigate(System.Uri)' 
has some invalid arguments  C:\Documents and Settings\User\Desktop\project\Tracking\Tracking\Form1.cs   322 17  
Tracking 

Error   2   Argument '1': cannot convert from 'string' to 'System.Uri' 
C:\Documents and Settings\User\Desktop\project\Tracking\Tracking\Form1.cs   
322 38  Tracking





我的代码是:





My code is:

private void getmap_Click(object sender, EventArgs e)
{
    webBrowser1.Show();
    if (currentLatitudeTbx.Text == string.Empty || currentLongitudeTbx.Text == string.Empty)
    {
        MessageBox.Show("Supply a latitude and longitude value", "Missing Data");
        return;
    }
    try
    {
        string lat = string.Empty;
        string lon = string.Empty;

        StringBuilder queryAddress = new StringBuilder();
        queryAddress.Append("http://maps.google.com/maps?q=");
        if (currentLatitudeTbx.Text != string.Empty)
        {
            lat = currentLatitudeTbx.Text;
            queryAddress.Append(lat + "%2C");
        }
        if (currentLongitudeTbx.Text != string.Empty)
        {
            lon = currentLongitudeTbx.Text;
            queryAddress.Append(lon);
        }
        webBrowser1.Navigate(queryAddress.ToString());

    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message.ToString(), "Error");
    }
 }


[更正的代码格式]


[Corrected code formatting]

推荐答案

请尝试以下操作:

Try this:

webBrowser1.Navigate(new Uri(queryAddress.ToString()));



您的问题是您试图将字符串传递给需要Uri对象的方法.



Your problem is that you''re trying to pass a string to a method that''s expecting a Uri object.


这篇关于如何使用C#在智能设备中使用Webrowser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆