473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

overrides help please

I have created a users control with a text box and button on it, what I want
to do is override the usercontrol Keydown events with that of the Text box.
What is the correct syntax to accomplish this?

Example of my text box sub:-
Private Sub Edit_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Edit.KeyDown
End Sub

Thanks
Nov 20 '05 #1
16 3225
Hello,

"Merlin" <je**@jg-tech.co.uk> schrieb:
I have created a users control with a text box and button on it,
what I want to do is override the usercontrol Keydown events
with that of the Text box. What is the correct syntax to accomplish
this?


What behavior would you expect?

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
"Merlin" <je**@jg-tech.co.uk> schrieb
I have created a users control with a text box and button on it, what
I want to do is override the usercontrol Keydown events with that of
the Text box.
???
Sorry, I don't get your intention.

What is the correct syntax to accomplish this?

Example of my text box sub:-
Private Sub Edit_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Edit.KeyDown
End Sub

--
Armin

Nov 20 '05 #3
Sorry, I'll try to make myself clearer:-

What I want to be able to do is place my UserControl on a form and then in
the UserControl KeyDown Event trap key presses from my text box that is
within the UserControl. So in otherwords override the UserControl KeyDown
Events with the Text box KeyDown Events.

Thanks,
Merlin
"Merlin" <je**@jg-tech.co.uk> wrote in message
news:bi**********@hercules.btinternet.com...
I have created a users control with a text box and button on it, what I want to do is override the usercontrol Keydown events with that of the Text box. What is the correct syntax to accomplish this?

Example of my text box sub:-
Private Sub Edit_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Edit.KeyDown
End Sub

Thanks

Nov 20 '05 #4
"Merlin" <je**@jg-tech.co.uk> schrieb
Sorry, I'll try to make myself clearer:-

What I want to be able to do is place my UserControl on a form and
then in the UserControl KeyDown Event trap key presses from my text
box that is within the UserControl. So in otherwords override the
UserControl KeyDown Events with the Text box KeyDown Events.


Now I think I understand - if you leave out the last sentence. ;-)

You can handle the textbox' keypress event in the Usercontrol:

Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress

End Sub

Still I don't think that's what you wanted to know, so...

--
Armin

Nov 20 '05 #5
Hello,

"Armin Zingler" <az*******@freenet.de> schrieb:
Sorry, I'll try to make myself clearer:-

What I want to be able to do is place my UserControl on a form and
then in the UserControl KeyDown Event trap key presses from my text
box that is within the UserControl. So in otherwords override the
UserControl KeyDown Events with the Text box KeyDown Events.


Now I think I understand - if you leave out the last sentence. ;-)

You can handle the textbox' keypress event in the Usercontrol:

Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress

End Sub

Still I don't think that's what you wanted to know, so...


I think merlin wants to forward/redirect the keyboard input of the textbox
to the usercontrol. Every time the user presses a key in the textbox, the
usercontrol's KeyPress event should be raised.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #6
Hi Merlin,

If the other responses haven't quite answered your question (I
find it quite ambiguous), can you tell us <why> you want this override
and what you hope to achieve?

Regards,
Fergus
Nov 20 '05 #7
Sorry, I'll try to make myself clearer:-

What I want to be able to do is place my UserControl on a form and then in
the UserControl KeyDown Event trap key presses from my text box that is
within the UserControl. So in otherwords override the UserControl KeyDown
Events with the Text box KeyDown Events.

Thanks,
Merlin
Nov 20 '05 #8
Hello,

"Merlin" <je**@jg-tech.co.uk> schrieb:
What I want to be able to do is place my UserControl on a form and then in
the UserControl KeyDown Event trap key presses from my text box that is
within the UserControl. So in otherwords override the UserControl KeyDown
Events with the Text box KeyDown Events.


Untested (!), code for the UserControl:

\\\
Private Sub TextBox1_KeyDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs _
) Handles TextBox1.KeyDown
MyBase.OnKeyDown(e)
End Sub
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #9
Ok here goes,

I have created a control that has a text box and a button at the end of the
text box, I want my control to totally emulate a text box, but have the
added addition of a button at the end. The idea of this control is to allow
a user to input text in the normal manner or press a button to display a
pick list.

Therefore I want the usercontrol events all overridden with the Text box
events. As it stands If I were to place my user control on a form and trap
the usercontrol keydown event when entering text, I'd only be trapping
events for the user control so get nothing whereas I want to trap the text
box events:-

i.e
instead of UserControl.TextBox1.Keydown
I want UserControl.Keydown to be exactly the same.

Hope thats clearer.

Thanks

Merlin.

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
Hi Merlin,

Lol. That's the <what>.
Can you tell us the <why> ?
This is the bit that everyone is struggling to understand. It really makes <no sense> to us at all, yet it's the bit that you haven't changed!!

Post 1: override the usercontrol Keydown events with that of the Text box
Post 2: override the UserControl KeyDown Events with the Text box KeyDown
Events
Post 3: override the UserControl KeyDown Events with the Text box KeyDown
Events
Tell us in human terms. - What effect do you want to achieve - for
yourself, for the user?

With curiousity and anticipation,
Fergus.

Nov 20 '05 #10
Merlin,
Say the following without using the word 'overridden'! :-|
Therefore I want the usercontrol events all overridden with the Text box
events.
I believe the word 'overridden' above is what is confusing every one about
your post.

If you want each TextBox event to raise the respective usercontrol event
then you need to do as I & Herfried pointed out earlier.

Note if you are not seeing OnKeyDown method from Herfried's & my earlier
posts, use "Tools - Options - Text Editor - Basic - General - Hide advanced
members" to see all the On* event methods in UserControl & Control.

Hope this helps
Jay
"Merlin" <je**@jg-tech.co.uk> wrote in message
news:bi**********@titan.btinternet.com... Ok here goes,

I have created a control that has a text box and a button at the end of the text box, I want my control to totally emulate a text box, but have the
added addition of a button at the end. The idea of this control is to allow a user to input text in the normal manner or press a button to display a
pick list.

Therefore I want the usercontrol events all overridden with the Text box
events. As it stands If I were to place my user control on a form and trap
the usercontrol keydown event when entering text, I'd only be trapping
events for the user control so get nothing whereas I want to trap the text
box events:-

i.e
instead of UserControl.TextBox1.Keydown
I want UserControl.Keydown to be exactly the same.

Hope thats clearer.

Thanks

Merlin.

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
Hi Merlin,

Lol. That's the <what>.
Can you tell us the <why> ?
This is the bit that everyone is struggling to understand. It really

makes
<no sense> to us at all, yet it's the bit that you haven't changed!!

Post 1: override the usercontrol Keydown events with that of the Text box Post 2: override the UserControl KeyDown Events with the Text box KeyDown Events
Post 3: override the UserControl KeyDown Events with the Text box KeyDown Events
Tell us in human terms. - What effect do you want to achieve - for
yourself, for the user?

With curiousity and anticipation,
Fergus.


Nov 20 '05 #11
Thanks Jay and Hertfried,

I thought overrides is what I needed, which is why like you said I confused
everyone.

Next question then:
What does override do or when should it be used?

Regards,
Merlin
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...
Merlin,
Say the following without using the word 'overridden'! :-|
Therefore I want the usercontrol events all overridden with the Text box
events.
I believe the word 'overridden' above is what is confusing every one about
your post.

If you want each TextBox event to raise the respective usercontrol event
then you need to do as I & Herfried pointed out earlier.

Note if you are not seeing OnKeyDown method from Herfried's & my earlier
posts, use "Tools - Options - Text Editor - Basic - General - Hide

advanced members" to see all the On* event methods in UserControl & Control.

Hope this helps
Jay
"Merlin" <je**@jg-tech.co.uk> wrote in message
news:bi**********@titan.btinternet.com...
Ok here goes,

I have created a control that has a text box and a button at the end of

the
text box, I want my control to totally emulate a text box, but have the
added addition of a button at the end. The idea of this control is to

allow
a user to input text in the normal manner or press a button to display a
pick list.

Therefore I want the usercontrol events all overridden with the Text box
events. As it stands If I were to place my user control on a form and trap
the usercontrol keydown event when entering text, I'd only be trapping
events for the user control so get nothing whereas I want to trap the text box events:-

i.e
instead of UserControl.TextBox1.Keydown
I want UserControl.Keydown to be exactly the same.

Hope thats clearer.

Thanks

Merlin.

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
Hi Merlin,

Lol. That's the <what>.
Can you tell us the <why> ?
This is the bit that everyone is struggling to understand. It
really makes
<no sense> to us at all, yet it's the bit that you haven't changed!!

Post 1: override the usercontrol Keydown events with that of the Text

box Post 2: override the UserControl KeyDown Events with the Text box KeyDown Events
Post 3: override the UserControl KeyDown Events with the Text box KeyDown Events
Tell us in human terms. - What effect do you want to achieve - for
yourself, for the user?

With curiousity and anticipation,
Fergus.



Nov 20 '05 #12
Hello,

"Merlin" <je**@jg-tech.co.uk> schrieb:
What does override do or when should it be used?


http://msdn.microsoft.com/library/en...ancebasics.asp
http://msdn.microsoft.com/library/en...yOverrides.asp

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #13
Lol, Merlin

Nice one.

Regards,
Fergus

ps. I'm only watching this one... ;-)
Nov 20 '05 #14
"Merlin" <je**@jg-tech.co.uk> schrieb
Ok here goes,

I have created a control that has a text box and a button at the end
of the text box, I want my control to totally emulate a text box, but
have the added addition of a button at the end. The idea of this
control is to allow a user to input text in the normal manner or
press a button to display a pick list.

Therefore I want the usercontrol events all overridden with the Text
box events. As it stands If I were to place my user control on a form
and trap the usercontrol keydown event when entering text, I'd only
be trapping events for the user control so get nothing whereas I want
to trap the text box events:-

i.e
instead of UserControl.TextBox1.Keydown
I want UserControl.Keydown to be exactly the same.

Hope thats clearer.


It is.

- Event bubbling: Handle the textbox' events in the usercontrol and, for
each event, raise an event in the usercontrol that can be handled outside
(lot of work).

- Make the textbox public (or friend). Outside the Usercontrol, you can use
Addhandler MyUserControlInstance.MyTextbox.Textchanged, addressof ...
--
Armin

Nov 20 '05 #15
Hi Merlin, Armin,

"And the prize goes to ..... Armin Zingler - for his Event Bubbling."

The ideal purpose of a UserControl is to provide a composite Control which
conforms as far as possible to the standards of the basic Controls. This means
that the designer (you) should do as much as possible to make your UserControl
interface act as expected for a Control.

Which means do the work!!

Regards, both,
Fergus
Nov 20 '05 #16
Cor
Hi,
Terrific good written Jay with very good in mind the not native speaking
English people.
Cor
Nov 20 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ECVerify.com | last post by:
I posted this earlier but never got a response...so I am trying again **************************** Hey everyone, I have a simple (I hope question) To get the events in C# I can go to the...
4
by: Christopher W. Douglas | last post by:
I am developing a VB.NET app using Visual Studio.NET 2003. VB.NET allows me to create a class with two or more methods that have the same name, as long as they have different (non-optional)...
5
by: ECVerify.com | last post by:
This should be a basic question. In VB.NET in the two drop downs over the source code for a form you can get a list of the events and overrides for that form. In VC++ in the properties window...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
9
by: Surrealist | last post by:
I need something likes as when I create an event procedure. I can use top-left and top-right dropdown list of code editor to select object and its exposed events respectively. Then, the IDE,...
2
by: Dot net work | last post by:
Hello, My simple code is here: Public Class MyDictionary Inherits System.Collections.DictionaryBase Private Class MyElement Public Overloads Overrides Function Equals(ByVal obj As Object)...
2
by: ljlevend | last post by:
I've noticed in VS.NET v2.0 Beta 1 that the (Overrides) item does not appear in the ComboBox that lists all of the classes in the current file (and also contains the General item and the ( Events)...
2
by: Kalvin | last post by:
I found some code in Google, don't remember where, for an AutoComplete combobox. Everything is great with it except for one thing. If I use the mouse to drop the list down, then start typing to...
2
by: Ron Dahl | last post by:
I'm very confused on how the Protected Overrides works. I created a new project with a new form1 and a new datagrid called myDataGrid. I created a simple DataTable and put 5 rows and 5 columns of...
0
by: Eric | last post by:
Can someone please tell me how to rectify this. The full error is: sub 'Dispose' cannot be declared 'Overrides' because it does not override a sub in a base class. Followed by: 'Dispose' is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.