
using the webbrowser ctl from C#
jobob,
The reason for this is that optional parameters are not supported in
.NET. Instead, you have method overloading. To make up for this in COM
interop, all the parameters are exposed on the method, and it is up to you
to pass in the "missing" parameters (which VB does under the covers).
To make your call, do the following:
// Declare a dummy object to pass in the missing values.
object pobjMissing = System.Reflection.Missing.Value;
// webBrowser1 is the Web Browser control.
webBrowser1.Navigate2("http://www.someplace.com", ref pobjMissing, ref
pobjMissing, ref pobjMissing, ref pobjMissing);
Hope this helps.
--
- Nicholas Paldino [.NET MVP]
Quote:
> When using the WebBrowser control from a VB application, i
> can call the Navigate2 method with only a URL in the form
> of a string ("http:www.msn.com") and bang it goes there.
> In my C# code, im trying to call the Navigate2 method from
> a button_click event. However, there is no version of the
> Navigate2 method that takes just a string. It requires
> ref paramaters passed also. help ? how about just using
> some variables of type 'Object', and just passing them in ?
> Here is what the VB object browser says about the
> Navigate2 method. In C#, the paramaters have the ref
> object modifiers added.
> Sub Navigate2(URL, [Flags], [TargetFrameName], [PostData],
> [Headers])
> help ?