Re: How to programmatically invoke Click event of the Button ?
- From: Mehdi <vioccc@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Mar 2006 10:05:54 +0000
On Fri, 24 Mar 2006 09:57:54 +0500, Oleg Subachev wrote:
You can use the PerformClick() function.
And what if I need to invoke another event ?
Or if I need to invoke an event of Label class ?
That of course won't work then. But your question was "How to
programmatically invoke Click event of the Button ?". I'm sorry but I don't
have yet the ability to read into usenet's users mind (but i'm working on
it).
As for your new question, wrapping the OnEvent() methods may be a solution
of course but it sounds like you are mixing a bit to much the UI code with
the application logic which ultimately tends to make the code difficult to
read and maintain. Much better in my opinion would be to clearly separate
those 2 layers. E.g., if you have a button "Take Order", then this button's
click event handler should call the TakeOrder() method. If you need to take
an order programmatically, you can call TakeOrder() instead of calling the
button's event handler. If the event handler of the button changes, this
shouldn't affect the rest of the application logic. Your code should be
able to determine what function to call at any time rather than blindly
calling the button's event handler hoping that it's gonna do the right
thing.
I think the best way is to put corresponding protected[...]
On<Event> method into the public wrapper.
I can't do this because Button's click event may contain different handlers
during execution of my application.
What would happen if later you decided to modify your UI and use 2 separate
buttons instead a single button with changing event handlers? If your code
was just calling your button's OnClick() method to do what the button was
supposed to do, you would have to go through all your code and try to find
out for each OnClick() call what you really wanted to do by calling
OnClick(). Plus i don't want to think of how difficult to read your code
would be to another programmer with OnClick() calls of a button which click
event handlers keep changing during the execution of the program.
.
- References:
- How to programmatically invoke Click event of the Button ?
- From: Oleg Subachev
- Re: How to programmatically invoke Click event of the Button ?
- From: Mehdi
- Re: How to programmatically invoke Click event of the Button ?
- From: Oleg Subachev
- How to programmatically invoke Click event of the Button ?
- Prev by Date: Re: List<T> Question
- Next by Date: How to add values to Dropdownlist in datagrid dynamically?
- Previous by thread: Re: How to programmatically invoke Click event of the Button ?
- Next by thread: Re: How to programmatically invoke Click event of the Button ?
- Index(es):
Relevant Pages
|