Thanks Cerebrus ! I will do it this way . I really apreciate your
help.

On Feb 16, 11:03 am, Cerebrus <[email protected]> wrote:
> Ohhh, I understand now ! You really should read up on "Delegates and
> Events". Also, you seem to be using the term "Event" and "routine"
> interchangeably, while they are different. An Event is handled by an
> Event handler, which is the routine you are referring to. Also, I'm
> not discussing the wisdom of having 50 checkboxes on a form (If I
> needed them, I'd probably create them dynamically or look into having
> another control deliver similar functionality.)
>
> You can attach multiple events to the same handler as long as their
> signature is the same. For example, all CheckedChanged events will
> have the same signature, so you attach all the events to the same
> handler. Assuming that this should be the filter_gen() method, you
> will need to change the signature of the method as follows :
>
> ---
> private void filter_gen(object sender, EventArgs e)
> {
>
> }
>
> ---
>
> Note that this matches the signature expected of a CheckedChanged
> event handler. Now you need to attach all the 50 events to your
> filter_gen method. You could do this in two ways :
>
> 1. Go to design view and in the Properties window, under the events
> section just set the CheckedChanged handler *for each* checkbox to
> your filter_gen() method. (Select it from the dropdown). You could do
> this in one step by selecting all 50 checkboxes and then setting the
> Eventhandler. The wire-up statements illustrated below will
> automatically be added by VS to the InitializeComponent() method.
> 2. Add wire-up statements such as the following for all 50 handlers at
> a startup phase of the form or in the constructor:
>
> private void Form1_Load(object sender, EventArgs e)
> {
>   checkBox1.CheckedChanged += new EventHandler(filter_gen);
>   checkBox2.CheckedChanged += new EventHandler(filter_gen);
>   checkBox3.CheckedChanged += new EventHandler(filter_gen);
>   //... and so on till 50
>
> }
>
> I recommend the first option. Let VS do some work !! ;-)
>
> On Feb 16, 1:28 pm, Nacho108 <[email protected]> wrote:
>
> > Yes, what I'm trying to do is using the same event (i.e. only one
> > rutine) to handle each individual event in each checkbox to generate
> > the string filter. I wouldn't want to generate 50 events rutine, one
> > for each checkbox.
>
> > For better understanding, the event I have with one checkbox does
> > this:
>
> >         private void S01_CheckedChanged(object sender, EventArgs e)
> >         {
> >             filter_gen();
> >         }
>
> > In this way the filter_gen() rutine generates the filter string
> > inmediately after the user check or uncheck a checkbox. The thing is
> > that I have 50 of these checkboxes and I don't know how to make ONLY
> > one rutine, instead of 50, one for each one of them.
> > Is there a way of doing this? or is it just impossible?

Reply via email to