braderz31

Hi,

Does anybody know how to toolstrip buttons work as back and forward buttons

(I already have the buttons i just need to know to make them work as web browser buttons!)



Re: Visual C# General Back/Forward buttons

Derek Smyth

Hi,

The web browser control provides a couple of methods and properties that help create forward and back buttons...

webBrowser.GoForward()
webBrowser.CanGoForward //boolean property

webBrowser.CanGoBack

webBrowser.GoBack()

Use these methods in the click event of your toolstrip buttons !






Re: Visual C# General Back/Forward buttons

braderz31

Hi,

I read your post and i got a popup window saying "PROPERTY VALUE IS NOT VALID"

Do you know why this is





Re: Visual C# General Back/Forward buttons

Sniper167

You don't need webBrowser.CanGoForward and webBrowser.CanGoBack... For your forward button you need to put webBrowser1.GoForward(); and for your back button you need webBrowser1.GoBack(); in your click events...

That's all you need!!





Re: Visual C# General Back/Forward buttons

braderz31

Still keep getting that popup window!!!!!





Re: Visual C# General Back/Forward buttons

decyclone


Use this example code :

public partial class FormWithWebBrowser : Form
{
public FormWithWebBrowser()
{
InitializeComponent();
}

private void toolStripButton1_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}

private void toolStripButton2_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}

private void FormWithWebBrowser_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(@"http://www.microsoft.com");
}
}

[Note : Designer code not included. Create a form, add a WebBrowser control, add a ToolStrip, add two ToolStripButton controls to the ToolStrip. And then attach the event handlers in these code to the appropriate events on the form].

I hope this helps.