Reputation: 3172
I am trying to create a 'tabbed' web browser in my C# program following the example I found at: http://www.c-sharpcorner.com/UploadFile/6e17c7/how-to-create-a-simple-multi-tabbed-webbrowser-in-C-Sharp/
However, having copied the code from this tutorial, and tried compiling it in Visual Studio, I get a compile error that says:
Type 'Form1' already defines a member called '.ctor' with the same parameter types
The code I am trying to run is:
namespace testBrowser
{
public partial class Form1: Form
{
WebBrowser webBrowser = new WebBrowser();
TabControl tabControl1 = new TabControl();
TextBox textBox1 = new TextBox();
public Form1()
{
InitializeComponent();
webBrowser.Navigate("www.google.com");
}
private void button3_Click(object sender, EventArgs e)
{
TabPage tabPage = new TabPage();
tabPage.Text = "New Page";
tabControl1.Controls.Add(tabPage);
//WebBrowser webBrowser = new WebBrowser();
webBrowser.Parent = tabPage;
webBrowser.Dock = DockStyle.Fill;
webBrowser.Navigate("www.google.com");
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser.Navigate(textBox1.Text);
}
private void button2_Click(object sender, EventArgs e)
{
if (webBrowser.CanGoBack)
{
webBrowser.GoBack();
}else
{
MessageBox.Show("You cannot go back");
}
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
textBox1.Text = webBrowser.Url.ToString();
}
}
}
I can't see .ctor
anywhere in the code... what does this compile error mean? The line it's complaining about is public Form1()
Upvotes: 0
Views: 1105
Reputation: 5405
Your class is partial , so you probably have the Form1()
constructor defined in another source file for your partial class and .ctor
It's just shorthand for "constructor" and it's what the constructor is called in IL.
Upvotes: 1