you need to post the entire solution really or more specifically give us details about what is happening as it would help.
what are you selecting is it a menu item if so, you need to make sure you have a click event so you can fire that event and navigate to the page you want.
again you need to give us more details about this :-)
that was just what i needed thanks. i Know this is bieng abit cheeky but do you have any idead on how to do the following. How to get a webpage to navigate to the selected Url
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; using System.Security.Policy; using System.Text; using System.Xml; using System.Xml.Serialization; using System.IO;
#endregion
namespace MyOwnTabbedBrowser { public partial class BrowserExplorer : Form { int current_tab_count = 0;
private string theURL = String.Empty;
ArrayList tabpages = new ArrayList(); ArrayList webpages = new ArrayList();
Types and Variables
brian_tsim
p.s I'm Using a tabs system
pps this is part of a favourites system.
BerW
zaynun hammoud
public string TheURL
{
get
{
return yourCombox.Text;
}
set
{
this.theURL = value;
}
}
JørnDev
But is a string property, must return a string.
Regards.
Yves1
you need to post the entire solution really or more specifically give us details about what is happening as it would help.
what are you selecting is it a menu item if so, you need to make sure you have a click event so you can fire that event and navigate to the page you want.
again you need to give us more details about this :-)
Pon t3h pony
Stark77
private void addNewFavouriteToolStripMenuItem_Click(object sender, EventArgs e)
{
Favorite theNewFavorite = new Favorite("displayName", "TheURL");
theNewFavorite.DoAddFavorite(theNewFavorite);
this.theFavoriteMenuToolStripItem.DropDown.Items.Add(theURL);
this.theFavoriteMenuToolStripItem.DropDown.Items[this.theFavoriteMenu
ToolStripItem.DropDown.Items.Count - 1].ToolTipText = theNewFavorite.TheURL;
}
and then that will create the Link in the Favourites menu.
so when the Link inside the favourites menu is clicked the Browser navigates to the URL
Code;
private void theFavoriteMenuToolStripItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate(theURL);
}
so this is my overall code;
#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Security.Policy;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
#endregion
namespace MyOwnTabbedBrowser
{
public partial class BrowserExplorer : Form
{
int current_tab_count = 0;
private string theURL = String.Empty;
ArrayList tabpages = new ArrayList();
ArrayList webpages = new ArrayList();
private Favorite theFavorites = new Favorite();
public BrowserExplorer()
{
InitializeComponent();
tabControl1.TabPages.Clear();
Create_a_new_tab();
WebBrowser webpage = GetCurrentWebBrowser();
webpage.GoHome();
}
public string TheURL
{
get
{
return this.theURL;
}
set
{
this.theURL = value;
comboBoxurl.Text = this.theURL;
}
}
public void DoAddFavorite(Favorite theFavToAdd)
{
this.theFavorites.Add(theFavToAdd);
}
public Favorite(string url)
{
theURL = url;
}
//*************************** Button Events ***************************//
private void tsbGo_Click(object sender, EventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate(comboBoxurl.Text);
}
private void tsHome_Click(object sender, EventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.GoHome();
}
private void tsBack_Click(object sender, EventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.GoBack();
}
private void tsForward_Click(object sender, EventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.GoForward();
}
private void tsStop_Click(object sender, EventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Stop();
}
private void tsRefresh_Click(object sender, EventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Refresh();
}
private void tsSearch_Click(object sender, EventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.GoSearch();
}
private void tlbNewtab_Click(object sender, EventArgs e)
{
Create_a_new_tab();
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate(comboBoxurl.Text);
}
private void addNewFavouriteToolStripMenuItem_Click(object sender, EventArgs e)
{
Favorite theNewFavorite = new Favorite("displayName", "TheURL");
theNewFavorite.DoAddFavorite(theNewFavorite);
this.theFavoriteMenuToolStripItem.DropDown.Items.Add(theURL);
this.theFavoriteMenuToolStripItem.DropDown.Items[this.theFavoriteMenuToolStripItem.DropDown.Items.Count - 1].ToolTipText = theNewFavorite.TheURL;
}
private void theFavoriteMenuToolStripItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate(theURL);
}
//*********************** Navigation Commands **************************//
private void ModifyNavigationButtons()
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
if (thiswebpage.CanGoBack)
tsBack.Enabled = true;
else
tsBack.Enabled = false;
if (thiswebpage.CanGoForward)
tsForward.Enabled = true;
else
tsForward.Enabled = false;
}
//*************************** Tab Controls ****************************//
private void Create_a_new_tab()
{
TabPage newpage = new TabPage("Loading...");
tabpages.Add(newpage);
tabControl1.TabPages.Add(newpage);
if (current_tab_count == 10) return;
WebBrowser webpage = new WebBrowser();
webpage.Parent = newpage;
webpage.Dock = DockStyle.Fill;
webpages.Add(webpage);
webpage.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webpage_DocumentCompleted);
webpage.GoHome();
tabControl1.SelectedTab = newpage;
}
void webpage_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
UpdateAllNames();
ModifyNavigationButtons();
}
private WebBrowser GetCurrentWebBrowser()
{
TabPage current_tab = tabControl1.SelectedTab;
WebBrowser thiswebpage = (WebBrowser)webpages[tabpages.IndexOf(current_tab)];
return thiswebpage;
}
private void UpdateName(TabPage tb)
{
TabPage current_tab = tb;
WebBrowser thiswebpage = (WebBrowser)webpages[tabpages.IndexOf(current_tab)];
if (thiswebpage.Document != null)
current_tab.Text = thiswebpage.Document.Title;
else
current_tab.Text = "Zzz";
}
private void UpdateAllNames()
{
// Update all the tab names for all the currently open web pages.
foreach (TabPage tb in tabControl1.TabPages)
{
UpdateName(tb);
}
}
private void comboBoxurl_KeyUp(object sender, KeyEventArgs e)
{
WebBrowser thiswebpage = GetCurrentWebBrowser();
if (e.KeyCode == Keys.Enter)
thiswebpage.Navigate(comboBoxurl.Text);
}
public void BrowserExplorer_Load(object sender, EventArgs e)
{
this.tsBack.Enabled = false;
this.tsbForward.Enabled = false;
this.theFavorites = Favorite.DoLoadFavorites();
foreach (Favorite currentItem in this.theFavorites.TheFavoritesCollection)
{
this.theFavoriteMenuToolStripItem.DropDown.Items.Add(currentItem.TheDisplayName);
this.theFavoriteMenuToolStripItem.DropDown.Items[this.theFavoriteMenuToolStripItem.DropDown.Items.Count - 1].ToolTipText = currentItem.TheURL;
}
}
}
public class Favorite
{
//****************** String Declaration **********************//
private string theDisplayName = string.Empty;
private string theURL = String.Empty;
private List<Favorite> theFavorites = new List<Favorite>();
//****************** String Definition ***********************//
public List<Favorite> TheFavoritesCollection
{
get
{
return this.theFavorites;
}
}
public string TheDisplayName
{
get
{
return theDisplayName;
}
set
{
theDisplayName = value;
}
}
public string TheURL
{
get
{
return theURL;
}
set
{
theURL = value;
}
}
public Favorite() { }
public Favorite(string displayName, string url)
{
theDisplayName = displayName;
theURL = url;
}
public int CompareTo(Favorite fav)
{
return TheDisplayName.CompareTo(TheDisplayName);
}
//**************Favourite Add/Load/Save Functions ****************//
public void DoAddFavorite(Favorite theFavToAdd)
{
this.theFavorites.Add(theFavToAdd);
}
public static Favorite DoLoadFavorites()
{
if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + "\\favorites.xml"))
{
//deserialize Type[] theTypes = new Type[1];
Type[] theTypes = new Type[1];
theTypes[0] = typeof(List<Favorite>);
XmlSerializer theSerializer = new XmlSerializer(typeof(Favorite), theTypes);
System.IO.StreamReader theReader = new System.IO.StreamReader(System.Windows.Forms.Application.StartupPath + "\\favorites.xml");
Favorite theFavorites = (Favorite)theSerializer.Deserialize(theReader);
theReader.Close();
return theFavorites;
}
else
{
return new Favorite();
}
}
public void DoSaveFavorites()
{
//serialize Type[] theTypes = new Type[1];
Type[] theTypes = new Type[1];
theTypes[0] = typeof(List<Favorite>);
XmlSerializer theSerializer = new XmlSerializer(typeof(Favorite), theTypes);
System.IO.StreamWriter theWriter = new System.IO.StreamWriter(System.Windows.Forms.Application.StartupPath + "\\favorites.xml");
theSerializer.Serialize(theWriter, this);
theWriter.Close();
}
}
}
is this clear enough
So what am i doing wrong
ScipBe
well if you are using a webbrowser control then to navigate to a webpage:
this.theWebBrowserControl.Navigate("http://someurl.com");
in your case it may well be:
this.theWebBrowserControl.Navigate(this.TheURL);
Eric Twietmeyer
mhorton
Try this:
public string TheURL
{
get
{
return this.theURL;
}
set
{
this.theURL = value;
comboBoxName.Text = this.theURL;
}
}
I hope this is what you need!
Best Regards,
evdberg
Regards.
iljanated
Xancholy
public string TheURL
{
get
{
return ComboBox;
}
set
{
this.theURL = value;
}
}
but i get the error message ;