473,383 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Exposing methods of controls in collection

I've satisfactorily got an axwebbrowser control on a form within a
panel, suitably positioned and sized, and now I want to display a
webpage on it. This is not normally a problem when I have the
control as a uniquely named object, since I would just use the
axweb.Navigate or Navigate2 method to send it to the right page.
However, it's part of a controls collection, accessible only via its
place in the collection.
[Form3, the form with the web browser]

Public Sub LoadWebBrowser()
If WebBrowserExists = False Then
Dim ax As New AxSHDocVw.AxWebBrowser
ax.Dock = DockStyle.Fill
Me.Controls.Add(ax)
WebBrowserExists = True
WebBrowserIndex = Me.Controls.Count - 1
End If
End Sub
As you can see, Form3.Controls(WebBrowserIndex) is the webbrowser
control. Now how do I set the page on the control? Using
ax.Navigate within this procedure gives me the following error

'An unhandled exception of type 'InvalidActiveXStateException'
occurred in systems.windows.forms.dll'

and is not ideal in any case, since I'm not sure if the object ax
will continue to exist outside this procedure. But trying to access
the method via

Me.Controls(WebBrowserIndex).Navigate

doesn't work at all, as Navigate is not a member of
System.Windows.Forms.Control, despite being a member of _that
particular_ control.

Incidentally, if anyone can get Form3 to locate and size
appropriately with an axwebbrowser control inside at designtime then
this will save me a lot of headaches. But I reckon I'll probably
want to access methods of controls in collections sooner or later, so
I'll still be grateful for help in this.
--
Cheers, ymt.
The endless moaner.
Apr 3 '06 #1
2 1544
Yuk Tang wrote:
I've satisfactorily got an axwebbrowser control on a form within a
panel, suitably positioned and sized, and now I want to display a
webpage on it. This is not normally a problem when I have the
control as a uniquely named object, since I would just use the
axweb.Navigate or Navigate2 method to send it to the right page.
However, it's part of a controls collection, accessible only via its
place in the collection.
[Form3, the form with the web browser]

Public Sub LoadWebBrowser()
If WebBrowserExists = False Then
Dim ax As New AxSHDocVw.AxWebBrowser
ax.Dock = DockStyle.Fill
Me.Controls.Add(ax)
WebBrowserExists = True
WebBrowserIndex = Me.Controls.Count - 1
End If
End Sub
As you can see, Form3.Controls(WebBrowserIndex) is the webbrowser
control. Now how do I set the page on the control? Using
ax.Navigate within this procedure gives me the following error

'An unhandled exception of type 'InvalidActiveXStateException'
occurred in systems.windows.forms.dll'

and is not ideal in any case, since I'm not sure if the object ax
will continue to exist outside this procedure. But trying to access
the method via

Me.Controls(WebBrowserIndex).Navigate

doesn't work at all, as Navigate is not a member of
System.Windows.Forms.Control, despite being a member of _that
particular_ control.

Incidentally, if anyone can get Form3 to locate and size
appropriately with an axwebbrowser control inside at designtime then
this will save me a lot of headaches. But I reckon I'll probably
want to access methods of controls in collections sooner or later, so
I'll still be grateful for help in this.


DirectCast(Me.Controls(WebBrowserIndex),AxSHDocVw. AxWebBrowser).Navigate

Placing "option strict on" at the top of your form will help you avoid
this issue in the future.

Chris
Apr 3 '06 #2
Chris <no@spam.com> wrote in
news:On**************@TK2MSFTNGP10.phx.gbl:

DirectCast(Me.Controls(WebBrowserIndex),AxSHDocVw. AxWebBrowser).Nav
igate

Placing "option strict on" at the top of your form will help you
avoid this issue in the future.


Thanks.
--
Cheers, ymt.
Apr 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
3
by: FredC | last post by:
How do you make a program's properties and methods availale so that other programs can "connect" to them at design time and then use them at run time?
2
by: wh | last post by:
I have a user control implemented in an .ascx page that I embed in the html as follows: <test:mycontrol runat="server" property1="..." property2="..."/> I'd also like to be able to assign a...
1
by: Jeff Smith | last post by:
Can I load custom web user controls dynamically and access the properties and methods without having to explicitly define custom control types (example 2 below). I have custom web control named...
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
3
by: Dave | last post by:
Please - anyone that can help. I am getting confusing results while trying to expose a collection from a web service. I have a webservice in which a web method accepts a collection as a...
4
by: =?Utf-8?B?QkogU2FmZGll?= | last post by:
We have a class that has a public property that is of type List<T>. FXCop generates a DoNotExposeGenericLists error, indicating "System.Collections.Generic.List<Tis a generic collection designed...
4
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a user control that is designed as below. I am creating these User Controls Dynamically in another form. They are multiple types of User Controls all with a common Interface so I can...
2
by: =?Utf-8?B?RGFsZQ==?= | last post by:
I have an app with a MasterPage. In the MasterPage is a user control with several public properties and methods that I want exposed to the content page. Rather than writing several redirection...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.