I have a combobox, if the "Enter" key is pressed will do something. but i want to call this function manually but how i send "ENTER" key as parameter?
private void carga_todos(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
do something
}
im trying this:
carga_todos(null, ??????)
Don't call events manually like that.
Move your logic into a separate method, which you can call whenever you like:
private void carga_todos(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
DoSomething();
}
}
private void AnotherFunctionThatNeedsToDoSomethingToo()
{
DoSomething();
}
private void DoSomething()
{
// stuff to do
}
I agree with Grant Winney. However, if your requirements are to call the handler directly then the following should work:
KeyPressEventArgs kpea = new KeyPressEventArgs((char)Keys.Enter);
carga_todos(null, kpea);
Good luck J
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With