private void toolStripButton1_Click(object sender, EventArgs e)
{
Navigate(toolStripComboBox1.Text);
}
private void toolStripComboBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Navigate(toolStripComboBox1.Text);
}
}
private void Navigate(String address)
{
if (String.IsNullOrEmpty(address)) return;
if (address.Equals("about:blank")) return;
if (!address.StartsWith("http://") &&
!address.StartsWith("https://"))
{
address = "http://" + address;
}
try
{
webBrowser1.Navigate(new Uri(address));
}
catch (System.UriFormatException)
{
return;
}
}
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
toolStripComboBox1.Text = webBrowser1.Url.ToString();
}
Do'stlaringiz bilan baham: |