Hi everyone! I'm making a web browser but I don't want 'webbrowser2' to be created on the form untill I click a button...
I tryed:
private
void button5_Click(object sender, EventArgs e){
WebBrowser
webbrowser2 = new WebBrowser();webbrowser2.Height = 250;
webbrowser2.Width = 279;
}
But it dosn't seem to be working (and i don't know how to set the location). Can someone please help me out!
THANKS!

Creating a web browser...
FredrikE
I think I found it (it was hiding)...
It is in the 'Form1.designer' file.
Stein
Can the left and top properties be used instead of location
I can't just make it not visible because i'm trying to stop the 'Connect to...' box from coming up (if they are offline) untill the user wants to access the web through my web browser (by pressing the button).
amm.firas
There's also left and top properties you need to set. An easier way would be to let it be created, but set it as not Visible ( visible = false ) and then make it visible when you want to see it.
njalkanen
Search your project, it's hidden in a 'compiler generated code' block, or something like that. If you're using VS2005, it's in a different file from the one you generally edit.
amercer
The only thing I could find that has the text InitialiseComponent is in the code for form1:
using
System;using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Text;using
System.Windows.Forms;using
fixmistakes;namespace
WindowsApplication1{
public partial class Form1 : Form{
public Form1(){
InitializeComponent(); //OVER HERE!
}
mbcoop
Right click on that and choose 'jump to definition' and it will take you to the code in another partial class.
samnas
Josh Free
hi,
you forgot to add the component on the fly to the form controls so it will not be displaied,
private void button5_Click(object sender, EventArgs e)
{
WebBrowser webbrowser2 = new WebBrowser();
webbrowser2.Height = 250;
webbrowser2.Width = 279;
//you have forgot to add those 2 lines
webbrowser2.Location =
new Point(20, 20); this.Controls.Add(webbrowser2);}
also you can add the control to the form and to hide it by useing visible property and when you click on the button to show it
in the form load event handler
webbrowser2.visible = False;
and in button click event handler
webbrowser2.visible = true;
hope that helps
Calvin FONG
Kumarsamy
Yeah, in VC#2005 you can define a class across multiple .cs files, and the designer does this to seperate your code from the code it generates.
Good luck !!
amitdevelopernet
I'm not sure. the best way to find out is to create one in the forms designer, and then look at hte code in InitializeComponent which creates the item. If you copy this code, you can't go wrong.
petersonmd