how to "see" click event from a usercontrol

C

Cor Ligthert

JohnR,

Some Dutchman expressly from Amsterdam, don't hear the difference between
the character z and s and are mostly using the s. I don't know however, I
assume that we do the same (and more things like that) in English. When we
speak English, we think in English, it is not a kind of translation. It is
changing your language completely, and than pronounce that. It is of course
the situation where we try to do it in the Oxford way or do it in the Dutch
way.

Nice story from you, however not good of course for this newsgroup,
therefore I don't make it to long although that it has my interest. However
in my opinion needed your message an answer

Cor
 
D

Debbie Carter

Stephany,
Bingo! You understood my point. If I were a software company and you
were looking for a programming job...you would be the first one I would
hire.
Debbie
 
D

Debbie Carter

We have a Dutch mayor in our little home town. When you walk into his office
he has a sign that hangs behind his desk that says, "If you ain't
Dutch...you ain't much".
 
D

Doug Taylor

I think that everyone is missing the point here.

Regardless of what language you are writing in - if the reader doesn't
understand the message then you have wasted your time.
I also think that native 'English' speakers should cut non native
'English' speakers a huge amount of slack. I often have to work in
French and I know how hard it is to be even reasonably comprehended in
a language that is not your own.

I do take your point, though, I feel we have a responsibilty to try
and understand non native English speakers

Doug Taylor
 
D

Debbie Carter

Actually I respect anyone that can speak or write in more than one language.

Debbie
 
S

Stephany Young

I'm afraid I have to disagree Doug.

If I was having a verbal conversation with someone for whom English was not
their first language, then I might be prepared to give some leeway,
depending on the effort they were putting in to making themselves
understood. In a verbal conversation one has other cues to help the
situation - facial expression, body language, gesticulation etc.

If, for example, I was going to be visiting France and I wanted to be
understood by the locals then it is my responsibility to learn French to the
standard where I can make myself understood. I do not expect the locals to
give me anyway leeway at all.

In the written medium, we do not have the luxury of visual cues, and
therefore it is even more important that what is written is as correct as it
possibly can be including grammar and punctuation. I'm sure that you are
well aware that a misplaced comma can completely change the meaning of a
sentence.

I will make the point that some of our friends in here for whom English is
not their first language actually have far better written English skills
than some of those for whom English is their first langauage.

I believe it is the responsibility of the write to make themselves
understood.
 
C

Cor Ligthert

Stephany,

I hope I don't offend you; however communicating is not using many words,
your message proofs for me that you don't know about what you're talking.

When I go to England, I speak English with the locals. When I go to Germany,
I speak German with the locals. However when I have really a conversation
with someone from Austria, we probably will use English. When I go to Italy,
I start mostly in French and after a while more and more Italian. When I go
to Spain (and that was the last times always the Catalonian coast) than it
is German. When I go to Poland, I try it in Polish. When I go to French, it
is French. When I go to the French speaking part of Belgium, I start in
French and after a while, we probably go over to Dutch. When a foreigner is
in the Netherlands, he/she can only communicate in English, German, or
French. In another language, including Dutch a Dutchman does normally not
communicate with what is obvious a foreigner.

You want to know why, that is because the language is only the layer we use
to communicate and we take the one, which is for the weakest one the most
easily to communicate.

The weakest one can be because of the ability of the other one to speak a
language or because of the cognisance performance of the other one.

Cor
 
C

Cor Ligthert

I'm sorry Cor but I have no idea what point you are attempting to make.Yes that is the problem that I try to describe.

However there is more needed than words alone to communicate.

Cor
 
C

Cor Ligthert

I believe it is the responsibility of the write to make themselves
understood.
By the way, what do you mean with the message above. I think that I am able
to understand what you mean. However, it is in my opinion real bs in the
context as you try to give lessons here.

Or has it to do in which way that in NZ is written about the bible?

Cor
 
S

Stephany Young

I can make spelling mistakes just a easily as anyone else.

It should have been:

I believe it is the responsibility of the writers to make themselves
understood.

See how easy it is to misunderstand if something is not written correctly.

Could you please explain what you mean by you last comment?
 
C

C-Services Holland b.v.

Stephany said:
I'm afraid I have to disagree Doug.

If I was having a verbal conversation with someone for whom English was not
their first language, then I might be prepared to give some leeway,
depending on the effort they were putting in to making themselves
understood. In a verbal conversation one has other cues to help the
situation - facial expression, body language, gesticulation etc.

If, for example, I was going to be visiting France and I wanted to be
understood by the locals then it is my responsibility to learn French to the
standard where I can make myself understood. I do not expect the locals to
give me anyway leeway at all.

In the written medium, we do not have the luxury of visual cues, and
therefore it is even more important that what is written is as correct as it
possibly can be including grammar and punctuation. I'm sure that you are
well aware that a misplaced comma can completely change the meaning of a
sentence.

I will make the point that some of our friends in here for whom English is
not their first language actually have far better written English skills
than some of those for whom English is their first langauage.

I believe it is the responsibility of the write to make themselves
understood.

Even been to the Netherlands? If so, did you learn Dutch? Didn't think
so. Your primary language is English so you have the luck that your
native language is one of the top languages in the world. I'm Dutch, I
don't have that luxery.

When tourists come to my country they expect us to speak their language,
or at least English. The region I'm in is popular with tourists and I
have yet to meet one that speaks Dutch or even attempts it. They all
think we're fluent in German, English, French or whatever. If I were to
try the same thing abroad (i.e. order some food in Dutch in England)
they would insist I speak English. I've travelled to alot of countries
and if you expect me to have learned all those languages you're out of
your mind. I'd be speaking at least 15 languages by now. I think 3 is
enough for me and by reading I can usually make out what it says in 2 or
3 additional languages. That's enough for me.

Point is, this is an international newsgroup. People from around the
world come here who's native language isn't English. You can't expect
them all to be fluent in English, either speaking or writing. You say it
needs to be grammatically correct. This is hard because alot of
languages differ greatly grammar wise. Not everyone has a knack for
speaking, let alone writing, another language. Just be glad we're not
all coming here writing our questions/answers in our native language and
expecting you to fully understand what has been written.
 
S

Stephany Young

That is my whole point. If I had ever been to the Netherlands than I would
have made the effort to learn Dutch to the
extent that I was able to make myself understood.

If the tourists to the Netherlands behave as you describe then that shows
that they are both arrogant and ignorant.

You are absolutely right, this newsgroup has an international
participantship. However, the language of this newsgroup is English. Seeing
as how the medium of this newsgroup is written, I don't really care how
fluent someone is or isn't, as the case may be, in spoken English. What I am
emphasising is that if one wants to make oneself understood in this medium
it is important that what one writes is phrased in a manner that others can
understand.
 
D

Debbie Carter

Stephany,

I totally agree. Especially if a person is trying to help everyone in the
newsgroup it would be best if they made their answers understandable to the
readers. This is why I kindly pointed out to Cor in the first place that it
would be good to take a refresher course or something in English. Why spend
so much time helping everyone when half of the people can not understand the
answers. I really don't have to say much more because anyone can read
through the newsgroup and see what I mean. I never meant to single out Cor
but the rest of the Dutch writers on here seem to be able to write answers
in English and I understand every word of it. Cor helped me a few times and
I did not get upset. From the things I could understand I took the advice. I
did not start a three mile long thread to argue why the help was wrong. I
might think different but when someone gives me corrective criticism I try
to use it to improve myself.

Debbie


Stephany Young said:
That is my whole point. If I had ever been to the Netherlands than I would
have made the effort to learn Dutch to the
extent that I was able to make myself understood.

If the tourists to the Netherlands behave as you describe then that shows
that they are both arrogant and ignorant.

You are absolutely right, this newsgroup has an international
participantship. However, the language of this newsgroup is English. Seeing
as how the medium of this newsgroup is written, I don't really care how
fluent someone is or isn't, as the case may be, in spoken English. What I am
emphasising is that if one wants to make oneself understood in this medium
it is important that what one writes is phrased in a manner that others can
understand.
 
C

Cor Ligthert

Rinze,

This is in my opinion not true, we don't allow foreigners to speak Dutch,
how hard they have trained on that. Generaly we directly start with speaking
English to them. When they are than German or French they have the change
that we will take that language.

There is a nice sarcastic page about that on Internet, however I cannot find
it anymore.

In that page is writen by instance, something that as somebody tries to
speak Dutch in Amsterdam, than he is direct a good object for a pickpocket,
because he obviously does not know the rules.

:)

Cor
 
C

Cor Ligthert

Debbie,

There is a minority of the English-speaking people, who think, that because
they can speak English that they are high above the rest of the world.

However, often are they to stupid to understand the problem and think than
that it is because the other ones lack to be able to write in errorless
English.

Lucky enough do Stephany and you not understand what I am writing and
therefore you cannot become upset from this message.

By the way, did you put your message in a spellchecker? In almost every
paragraph, there is an error.

Cor
 
C

Cor Ligthert

Stepahny

What do you mean with this word
participantship.

Participants hip maybe, what has that to do with this?

I really don't understood how you dare to write this messages with so many
errors in your own messages.

I even guess that you have an English spellchecker on your mail system,
where the non native English writers have often that not standard activated.

Cor
 
D

Debbie Carter

Cor,
Please point out the mistakes and I will be happy to correct them and
learn from you.
Thank you,
Debbie
 
J

JohnR

After researching various possibilities, I have found a solution that works
for me. I've written it up as a sort of tutorial so that if others are
confused about events and handlers it might help them understand the
concepts better.



Again, the original problem was "how to 'see' events generated from a
control in that control's parent container".

Example, let's say you have a usercontrol that has a button on it. If you
drag your usercontrol onto your form and create a "click" event handler for
it, your click event handler will get called if the user clicks on any part
of your usercontrol except the button. If the user clicks on the button in
the usercontrol your click event handler does not get called.



Problem analysis:

Each control has it's own 'click' event defined. The click event for the
usercontrol is different and distinct from the click event of the button in
the usercontrol. So what you want to do is somehow create a new 'click'
event that both the usercontrol and button can use.



There are a couple of ways to handle this. both involve defining a click
event in your usercontrol that will be shared by the usercontrol and the
button. Let's look at the more involved way first, then I'll show you an
easier way.



The tool that we will use in our solution is the RAISEEVENT statement. This
statement will raise an event that has been defined in your module. The
tricky thing is that you CAN'T use raiseevent to raise an event that has
been defined outside of your module. So, for example, you can't use
raiseevent to raise a standard 'click' event because you have not defined
the standard click event in your module. We need to define our own event.



So, lets start by going into our usercontrol module and defining an event.
Now, even though it's your event and you can define as many or as few
parameters as you wish, let's create an event that has the same number and
type of parameters as the standard "click" event (you'll find out why
later).



Public Event MyClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)



Now that we have defined an event in our usercontrol, we can use the
raiseevent statement to raise that event. But where do we raise it? Just
because we created our own event doesn't mean that the standard system
events are gone. they are still there and we can use them. Specifically, we
need to create a sub for both the click event of the usercontrol and the
click event of the button on the usercontrol and that's where we put our
raiseevent statement.



The click event for the usercontrol will look something like this:



Private Sub UserControl_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Click

RaiseEvent MyClick(sender, e)

End Sub



And the click event for the button (assume it's name is Button1) will look
like this:



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

RaiseEvent MyClick(sender, e)

End Sub



Now, what happens to the MyClick event when it's raised? It looks for
something to tell it where to go. That something is called a Delegate. A
Delegate links the event to the routine that will handle it. Now, if you've
used VB.Net at all you have probably used delegates without realizing it.
As a matter of fact, you used one already. The "Handles" clause above is a
delegate that links the "Button1.Click" event to the "Button1_Click" sub.

The "Handles" is one form of specifying a delegate. Although it doesn't
apply to our example, another way (at runtime) to specify (or change) a
delegate is by using an ADDHANDLER statement, like this:



AddHandler Button1.Click, AddressOf Button1_Click1



Back to our story. we need to go into our form where the usercontrol is
being used, and create something to handle our 'MyClick" event. So we will
need code like this:



Private Sub MyButton1_Click1(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyButton1.MyClick

MsgBox("I clicked MyButton1 on the main form")

End Sub



In the above example MyButton1 is the name we gave to the instance of the
usercontrol we dragged onto the form. So MyButton1 is an instance of
"usercontrol".

When the usercontrol class raises the event, that event is raised on every
class that has elected to handle events for that instance of the object.
The "Handles MyButton1.MyClick" tells the system that this routine will
handle the event raised in the "usercontrol" class instance called
"MyButton1". Wow, I hope that's clear..



We could stop here and everything above would work fine, but I promised you
an easier way to do the same thing.



Remember that to get our example to work we created a custom event in the
usercontrol class, and added a "handler" or "delegate" in our main form to
handle that event. We can cut our work in half by creating an event in our
usercontrol that has THE SAME NAME as an event that our main form already
knows about. What could we call the event??? How about "Click". Our main
form already knows about the "click" event, and by naming our own event
"click" we wouldn't have to make any changes in the main form. We would
just handle the "click" event in the main form as we normally would.
Therefore, the only changes we need would be in our usercontrol code. So,
how exactly do you create your own event that has the same name as an
already existing event? The answer is that you have to use the SHADOWS
keyword when defining your event. When an event is declared with the
shadows keyword it "hides" the existing event and, your custom event sort of
takes over for that original event. Here's how it looks in code. Put this
in the usercontrol class outside of any procedures.



Public Shadows Event Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)



This statement takes the place of the "Public Event MyClick" that we used
before. Now that you are using "Click" as the name of your event instead of
"MyClick" the RaiseEvent statement has to look like this:



RaiseEvent Click(sender, e)



Remember that, like the previous example, the RaiseEvent statement is in the
event handlers for the "click" event for your usercontrol and the button on
your usercontrol. So why is this not a conflict? How does the system
differentiate between your click event and the normal click event? It's
actually easy. When you specify a handler for the click event in the normal
way (ie: ..handles button.click or handles mybase.click) the system
defaults to using the standard system event. But the RaiseEvent, by
definition, can only raise an event that was defined in the module it's in,
so the RaiseEvent can ONLY raise the click event that you defined.



By shadowing the system click event you eliminated the need to make any code
changes in the main form. This is why, in the previous example, I chose to
define my custom click event with the same number and type of parameters as
the standard system click event. I knew that I would eventually be
"replacing" the standard click event with my own and wanted the parameters
(ie: signature) to match. To continue the explanation, simply dragging your
usercontrol onto your main form and setting it's "click" event (as you would
normally do for any control) works just fine with your custom 'click' event,
and anywhere you click on your usercontrol, that usercontrol's click event
will be fired. Just what we wanted..



Hope this helps clear up the concept of events and how to handle them.



John
 
C

C-Services Holland b.v.

Cor said:
Rinze,

This is in my opinion not true, we don't allow foreigners to speak Dutch,
how hard they have trained on that. Generaly we directly start with speaking
English to them. When they are than German or French they have the change
that we will take that language.

Maybe in Amsterdam. But here in Zeeland we don't.. up to a point. In
summer they (shops) expect every customer to be German and start talking
to you in German ;)

If someone starts off in Dutch, no matter how crooked, we don't
automatically switch to German/English or whatever.
 

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