Search code examples
c#winformstimertextchanged

Make a timer perform bidder00_TextChanged Event


I am trying to figure out how to make it that when my timer ticks, it performs a bidder00_TextChanged, or something like that.

Is this even possible to do? and if it isn't, is there any other way to do it? I tried to search Google for it but i didn't get any results, if you find anything that i missed please post it here.

I don't really have any code but here it is:

private void bidder00_TextChanged(object sender, EventArgs e)
{
    if (bidder00.Text == addbidder1.Text)
    {
        bidBtn1.PerformClick();
    }
}

That is my TextChanged Event

My timer doesn't have any code because it is going to perform the bidder00_TextChanged Event.


Solution

  • You could create a method Perform() and call it from within your event handlers :

    private void timer1_Tick(object sender, EventArgs e)
    {
       Perform();
    }
    
    private void bidder00_TextChanged(object sender, EventArgs e)
    {
       Perform();
    }
    
    private void Perform()
    {
       if (bidder00.Text == addbidder1.Text)
       {
          bidBtn1.PerformClick();
       }
    }