Hi
I have a function in one class that i wish to fire from another class but it just dosent seeem to happen, I have tried delegates to inform the class containing the method to fire the event that an event has been fired in the other class. I have also tried making a new instance of the class with the method and alough it runs it dosent function as it should.
this is maybe better explained if i describe it that one class has a web browser and a method to connect to a link, The other class also has a method that I wish to run the method(to connect to a link in the first class from).
If I create a new instance of the class containg the web browser in the method of the second class and run the method to navigate to a web site which is contained in the first class, when it fires the browser does nothing.
Can anyone help me here and maybe show me how to do this. Many Thanks
Loading
Satish KathiPosted Jul 18, 2008, 12:31 PM
Here is the code
ClassA (exactly same as yours)
public void OnWindowsUpgrade(object sender, EventArgs e)
{
//SwitchPanes(Panes.WEB_PANE);
if (null != webBrowser1)
{
webBrowser1.Navigate("http://www.google.co.uk");
//WaitForPageToLoad();
}
}
Class B I have added only one statement thisclass.show()
public void Windows_UpgradeEvent(object sender, EventArgs e)
{
ClassA thisclass = new ClassA();
thisclass.OnWindowsUpgrade(this, e);
thisclass.Show();
}
Hope this helps
klkfds lkjlkPosted Jul 18, 2008, 12:01 PM
the web browser control is in class a with the method that i am trying to launch,
Ryan AlfordPosted Jul 18, 2008, 9:15 AM
klkfds lkjlkPosted Jul 18, 2008, 4:23 AM
public void OnWindowsUpgrade(object sender, EventArgs e)
{
SwitchPanes(Panes.WEB_PANE);
if (null != webBrowser1)
{
webBrowser1.Navigate("http://www.google.co.uk");
WaitForPageToLoad();
}
}
this function is in class a.
the function that i want to fire this function from looks like this and is in class b
public void Windows_UpgradeEvent(object sender,EventArgs e)
{
// hav etried creating a new instance of class a
classa thisclass = new classa();
thisclass.OnWindowsUpgrade(this,e);
//works calls and steps through the function in class a but dosent navigate the web browser to the page.
}
I have also tried delegates alough i am not to confident with them and may be using them wrong. The function public void OnWindowsUpgrade(object sender, EventArgs e)works ok in its own class. both classes are in different name space if that makes a difference
one is in
namespace project (classa)
namespace projectl.Forms(classb)
hope you can help me many thanks
Ryan AlfordPosted Jul 17, 2008, 2:01 PM