3 Replies - 260 Views - Last Post: 10 June 2010 - 06:14 AM Rate Topic: -----

#1 fingers1989  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 28-May 10

visual studio again?

Posted 10 June 2010 - 05:42 AM

hi again everybody,

im stuck with opening a new form window while making a web browser in c#

heres the code i have now;

private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.browser.NewWindow();
        }



but i have also tried;

private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.NewWindow();
        }



the errors Im having are:


Error 1 The event 'System.Windows.Forms.WebBrowser.NewWindow' can only appear on the left hand side of += or -=

any help guys? i want it to open a new window, just like you do in any other browser or application

thanks!

This post has been edited by eclipsed4utoo: 10 June 2010 - 05:43 AM
Reason for edit:: please put your code inside the code tags...[code]your code here[/code]


Is This A Good Question/Topic? 0
  • +

Replies To: visual studio again?

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: visual studio again?

Posted 10 June 2010 - 05:51 AM

NewWindow is an event, not a method.

This is how you would use it...

private void Form1_Load(object sender, EventArgs e)
{
    WebBrowser b = new WebBrowser();
    b.NewWindow += new CancelEventHandler(b_NewWindow);
}

void b_NewWindow(object sender, CancelEventArgs e)
{
    // some code
}


Was This Post Helpful? 1
  • +
  • -

#3 fingers1989  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 28-May 10

Re: visual studio again?

Posted 10 June 2010 - 06:09 AM

View Posteclipsed4utoo, on 10 June 2010 - 04:51 AM, said:

NewWindow is an event, not a method.

This is how you would use it...

private void Form1_Load(object sender, EventArgs e)
{
    WebBrowser b = new WebBrowser();
    b.NewWindow += new CancelEventHandler(b_NewWindow);
}

void b_NewWindow(object sender, CancelEventArgs e)
{
    // some code
}



Ahh i see, so in my form, where i go to file>new window... how would i use it ?
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,663
  • Joined: 23-August 08

Re: visual studio again?

Posted 10 June 2010 - 06:14 AM

It's a new window, dude...I think you will need to create a new form and embed another WebBrowser control.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1