
Adding WebBrowser control at runtime
When you drag and drop a Web Browser from the toolbar, it
automatically updates the .resx file, such as Form.resx. It adds the
resource data for you. If you're writing this by hand, you also have to
add the information to resx by hand. Go to the Folder where your
application is stored and click on the .resx file.
Now, add the following information:
name: $this.wb.OcxState
mimetype: application/x-microsoft.net.object.binary.base64
You can leave the other fields blank, value: empty, comment: (null),
type: (null)
Now, your application should work fine.
Chris R.
Quote:
> Hi,
> I want to create a WebBrowser control at run time. I tried to use the
> code which is added to InitializeComponent function when adding the
> control at design time.
> I've added the following code:
> if (wb != null)
> {
> wb.Dispose();
> }
> System.Resources.ResourceManager resources = new
> System.Resources.ResourceManager(typeof(frmViewer));
> this.wb = new AxSHDocVw.AxWebBrowser();
> ((System.ComponentModel.ISupportInitialize)(this.wb)).BeginInit();
> this.Controls.AddRange(new System.Windows.Forms.Control[]
> {this.tbViewer,this.wb});
> ((System.ComponentModel.ISupportInitialize)(this.wb)).EndInit();
> this.wb.Anchor = System.Windows.Forms.AnchorStyles.None;
> this.wb.Enabled = true;
> this.wb.Location = new System.Drawing.Point(8, 32);
> this.wb.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("$this.wb.OcxSt
Quote:
> ate"))); // Error!!!
> this.wb.Size = new System.Drawing.Size(768, 560);
> this.wb.TabIndex = 1;
> When running the line which sets OcXState, it crashes because
> resources.GetObject("$this.wb.OcxState") returns null.
> How can Is solve that?
> Thanks
> Erez
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!