(C#)Navigate To URL
This code will allow your text box to be used as a navigate to URL bar, this will work with a web browser placed on your program.
Note : To get this to navigate to a URL, you will need to make a Go button to activate this code. (Go to bottom of thread to see code for this button)
public void NavigateToUrl() { Uri URL = default(Uri); try { URL = new Uri(textboxname.Text); } catch { try { URL = new Uri("http://www." + textboxname.Text); } catch { return; } } if ((URL.HostNameType == UriHostNameType.Dns) | (URL.HostNameType == UriHostNameType.IPv4)) { webbrowsername..Navigate(textboxname.Text); } else { string Host = URL.Host; Host = "http://www." + Host; try { webbrowsername.Navigate(Host); } catch { } } }
Go Button Code
private void gobutton_Click(object sender, EventArgs e) { if (ProgressBar1.Value < 100) { ProgressBar1.Value = 0; } NavigateToUrl(); if (ProgressBar1.Value < 100) { ProgressBar1.Value += 25; } }
Enjoy
-Lakar
- Guepassorse likes this