This tutorial show you how to deal with a C# and forms using Visual Studio Community 2017.
You need to start your project with C# – Windows Form Apps (.NET Framework).
On this default form window project you can change title and some settings like size, colors .
After that , you need to add editbox and label for each area from country , city street and number to window form.
In my example I used text_country for the name of editbox and I let default label1 for the label. The text from label1 I changed to Country to see it on form.
Make this changes for each editbox and label.
You need to have one button named search map point and one webbrowser area to show the location on map.
Next, press on button and make the changes into source code to work with webbrowser area.
The source code is simple – see bellow sorce code and the application screenshot.
The application can be found here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace GoogleMaps { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void search_Click(object sender, EventArgs e) { string country = text_country.Text; string city = text_city.Text; string street = text_street.Text; string nr = text_nr.Text; try { StringBuilder querryadress = new StringBuilder(); querryadress.Append("https://www.google.ro/maps/place/"); if(country != string.Empty){ querryadress.Append(country+"+"); } if (city != string.Empty) { querryadress.Append(city + "+"); } if (nr != string.Empty) { querryadress.Append(nr + "," + "+"); } webBrowser1.Navigate(querryadress.ToString()); } catch (Exception ex){ MessageBox.Show(ex.Message.ToString(),"Error search location...!"); } } } } |