|
I am trying to click a button programmatically.
If I click the button with my mouse it works fine by going out to the internet and asking for info the website thens sends the info requested.
However I have this on a timer (DelegateTimer, found here)
When the timer sends the request to "ButtonUpdatesPerformClick()" the .PerformClick does not work below.
I cannot bypass the button by going to "NonButtonUpdates()", because when it goes out to the internet, the information never comes back.
Can anyone help me with this problem.
Thanks in advance.
Michael
delegate void SetUpdatesCallback();
public void ButtonUpdatesPerformClick()
{
if (this.buttonUpdates.InvokeRequired)
{
SetUpdatesCallback button = new SetUpdatesCallback(this.ButtonUpdatesPerformClick);
this.Invoke(button, new object[] { });
}
else
{
this.buttonUpdates.PerformClick();
}
}
private void buttonUpdates_Click(object sender, EventArgs e)
{
this.NonButtonUpdates();
}
private void NonButtonUpdates()
{
this.GoToWebsiteGetData();
}
modified 20-Nov-12 22:59pm.
|
|
|
|
|
Your code makes zero sense. Have your click handler call a private method with no arguments DoStuff() for example. You don't want to click the button programatically, now do you? Do you actually want the button to press itself visually as if by magic? Probably not. You just want the code behind it to execute. So your timer or whatever would also just call the DoStuff() method directly.
modified 21-Nov-12 12:50pm.
|
|
|
|
|
You can call your click Event in simple method whenever you required.There is no need of button click.
|
|
|
|