Events heirdom

  • Thread starter Mateusz [PEYN] Adamus
  • Start date
M

Mateusz [PEYN] Adamus

Hi

I have 2 forms, like this:

Form2 : Form1

On Form1 I have a button1_Click event.

On Form2 no event is set.


When I Click button1 on Form2 the onClick event is fired two times. I
figured that its because Form2 is made out of Form1, so program actually
has two events, one on Form2 and second one on Form1.


Am i correct?

How can I prevent from firing onClick event second time?


bets regards
Mateusz [PEYN] Adamus

PS: How do you say in english something like this -> Form2 : Form1 ??
I got heirdom from some web dictionary but I'm not sure if this is
correct :)
 
D

Dmytro Lapshyn [MVP]

Hi,
PS: How do you say in english something like this -> Form2 : Form1 ??

Form2 inherits Form1 (the noun will be 'inheritance').
When I Click button1 on Form2 the onClick event is fired two times. I

It's a very strange behavior. All inherited stuff is not duplicated, if you
have an event in a base class, you will still have the same event in the
derived one. Just make sure you don't add a handler for button_Click in
Form2 to raise the onClick event if Form1 already does so.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Mateusz [PEYN] Adamus said:
Hi

I have 2 forms, like this:

Form2 : Form1

On Form1 I have a button1_Click event.

On Form2 no event is set.


When I Click button1 on Form2 the onClick event is fired two times. I
figured that its because Form2 is made out of Form1, so program actually
has two events, one on Form2 and second one on Form1.


Am i correct?

How can I prevent from firing onClick event second time?


bets regards
Mateusz [PEYN] Adamus

PS: How do you say in english something like this -> Form2 : Form1 ??
I got heirdom from some web dictionary but I'm not sure if this is correct
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top