PC Review


Reply
Thread Tools Rate Thread

Creating a UserControl

 
 
Tony Johansson
Guest
Posts: n/a
 
      5th Jul 2008
Hello!

I'm reading in a book and here they says.
"Now it is time to begin thinking about which events the control should
provide. Because the control is
derived from userControl class, it has inherited a lot of functionality that
you don't need to worry about.
There are, however, a number of events that you don't want to hand to the
user in the standard way.
Examples of this include the KeyDown, KeyPress and KeyUp events. The reason
you need to change
these events is that users will expect them to be sent when they press a key
in the textbox.
As they are now, the events are only sent when the control itself has focus
and the user presses a key.
To change this behavior, you must handle the events sent by the text box,
and pass them on to the user.
Add the KeDown, KeyUp, and KeyPress events for the text box and enter the
following code."

Now to my question what do they mean with saying this in the text above
"There are, however, a number of events that you don't want to hand to the
user in the standard way.
Examples of this include the KeyDown, KeyPress and KeyUp events. The reason
you need to change
these events is that users will expect them to be sent when they press a key
in the textbox.
As they are now, the events are only sent when the control itself has focus
and the user presses a key.
To change this behavior, you must handle the events sent by the text box,
and pass them on to the user. "

Can somebody explain that

private void txtLabelText_KeyDown(object sender, KeyEventArgs e)
{
OnKeyDown(e);
}

private void txtLabelText_KeyUp(object sender, KeyEventArgs e)
{
OnKeyUp(e);
}

private void txtLabelText_KeyPress(object sender, KeyPressEventArgs e)
{
OnKeyPress(e);
}

//Tony


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating UserControl with VB6 for excel Mika Microsoft Excel Programming 2 29th Nov 2010 04:53 PM
Creating a simple UserControl from a TextBox Tony Johansson Microsoft C# .NET 7 7th Jun 2009 05:32 PM
problem with creating a variable for usercontrol...? msnnews.msn.com Microsoft ASP .NET 0 20th Aug 2006 09:49 AM
Creating a UserControl that is bigger than the space it has in it'swindow Rune Jacobsen Microsoft C# .NET 0 13th Jul 2006 04:21 PM
error creating windows handle in usercontrol terrasamba Microsoft VB .NET 2 3rd Oct 2003 04:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:49 PM.