Background - I've create a windows application in VS and added a WebBrowser component and all works well.
I'm now trying to do this programmatically. My application now listens on a socket and when it receives a request it creates a new Form and adds a new WebBrowser.
The problem - All works well without the WebBrowser, the form is visible, but when I do "Controls.Add(webBrowser)" I see nothing, not even something in the windows bar.
Heres the constructor from my class that extends Form...
Expand|Select|Wrap|Line Numbers
- public partial class Browser : Form
- {
- public Browser()
- {
- // InitializeComponent();
- SuspendLayout();
- webBrowser = new WebBrowser();
- webBrowser.AllowWebBrowserDrop = false;
- webBrowser.Dock = DockStyle.Fill;
- webBrowser.IsWebBrowserContextMenuEnabled = false;
- webBrowser.Location = new System.Drawing.Point(0, 0);
- webBrowser.MinimumSize = new System.Drawing.Size(20, 20);
- webBrowser.Name = "webBrowser";
- webBrowser.ScrollBarsEnabled = false;
- webBrowser.Size = new System.Drawing.Size(292, 273);
- webBrowser.TabIndex = 0;
- webBrowser.WebBrowserShortcutsEnabled = false;
- webBrowser.Visible = true;
- AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- ClientSize = new System.Drawing.Size(292, 273);
- Controls.Add(webBrowser);
- Name = "Browser";
- ResumeLayout(true);
- WindowState = FormWindowState.Maximized;
- }
Thanks.