Re: Simulating events. Calling Click on a button



"Pieter Breed" <pieter.breed@xxxxxxxxx> a écrit dans le message de news:
1154680986.609275.131100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

| I would like to simulate UI events on UI controls. For example, I would
| like to make a button control think its been Clicked (from an outside
| class), so it would go through the click animation, raise the
| associated events etc.
|
| Is there a way to do this?

Why not separate out the code into another method and call that method from
the Click event, then you can call the separate method from other code ?


public partial class Form1 : Form
{
public void MyMethod()
{
// do stuff
}

private void button1_Click(object sender, EventArgs args)
{
MyMethod();
}
}


Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


.