Well, for a small amount of components, maybe there is no difference,
but for a bulky form with many controls, would not it be a big long
list, which is unnecessaryly long. Does anyone remember the classic
win32 message loop?. On the original subject, no matter what burden it
puts on the shoulder of designers, I'd like to find every piece of
comfort in my favorite language, and using more types in switch would be
fine :)
regards
Seref Arikan
Mike Andrews wrote:
I totally disagree.
There's nothing wrong with handling all of a group of buttons in a
toolbar
with a common event handler. Makes it much easier to read and find later
and subsequently work with.
Take this for example: (I'll use VB here)
Select Case (True)
Case (Sender = btnBold)
'Set bold
Case (Sender = btnUnderline)
'Set underline
Case (Sender = btnItalic)
'Set italic
End Select
This works so much better, especially since each of these is one line. I
only have one place to look and I don't have to have 3 separate event
handlers for what amounts to the same thing.
If it was so "daft" as you put it, then why do we have the
capability? Why
did MS put the idea of a "sender" in every event handler if it was never
necessary, or required, or useful? Having the sender is daft as well by
that reasoning.
On 6/20/06, John Brett <[EMAIL PROTECTED]> wrote:
<snip/>
> Why is that? If C# is modern language, why does it not have some very
> simple abilities that VB has had?
> It seems that if you want to have one procedure handle the click
events
for
> several buttons, that doing it this way is harder to read:
Whilst failing to answer your question completely, I'd like to say that
using 1 event handler to handle events from multiple objects, and then
doing something different for each is just plain daft.
If you have different functional requirements for each button, then
write
a separate event handler for each. If you have some common requirements,
then refactor that out into a worker function.
John
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com