Re: OOP style



On 30 Aug 2005 05:46:20 -0700, "swansnow"
<schultz@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

>> The root of all evil, if not avoided, is putting functionality > > into event handler methods of forms.
>
>I'm interested in hearing more about this.
>
>Say I have a form, and I need to limit the kind of characters allowed
>in the edit controls. So I hook each one up to the following event
>handler (below). Are you saying that I shouldn't do that? Instead, I
>should put this code into another unit (maybe a reusable library), and
>then simply call it from the event handler?

If this is going to happen a lot then I would create a descendant of
the TEdit control that has an extra property ( ValidChars maybe ) and
use that

It might reside in the Form's unit if it is unlikely to be used
elsewhere, especially if one is just doing a few tweaks, but
eventually it would probably land up in another unit either on its own
or with similar descendant controls


.



Relevant Pages

  • Re: Event Handler doesnt fire immediately upon postback?
    ... make its comparisons and work with the PostBack event handlers. ... It seems like such a waste of resources to me sometimes to use controls like ... I still prefer to do as much client-side processing as possible ... the event handler fires immediately. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Help me with threads.
    ... > controls from a worker thread, I disagree that dealing with this situation ... > public delegate void StringEventHandler(object worker, StringEventArgs e); ... > part, BeginInvoke needs a pointer to our event handler, plus an object ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help me with threads.
    ... What you need to do is to define an event that your worker thread can throw ... when it needs to send data back to the UI thread, create an event handler to ... sure that you're in the correct thread before you update your UI controls. ... StringEventArgs e); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Event Handler doesnt fire immediately upon postback?
    ... ASP.Net programming model, coming from Classic ASP, which is entirely ... Controls within Controls in the Page, which is, itself, a Control. ... previous state (prior to the PostBack), and only then does the Page (and ... the event handler fires immediately. ...
    (microsoft.public.dotnet.framework.aspnet)
  • MethodInfo.Invoke on unknown method of ActiveX control at runtime
    ... I have a bunch of ActiveX/OCX controls which I have run through AxImp to ... __GridDisplay_LaunchApplicationEventHandler(object object, IntPtr method) ... I got the above information from Reflection API on MyControl, ... an instance of the event handler which I will not know until runtime. ...
    (microsoft.public.dotnet.framework.interop)