Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Focus() in Control vs. UserControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
milund - 19 Oct 2007 10:45 GMT
Hi,

I am in the process of writing a custom control. In the OnMouseDown
method I call this.Focus() to enable the control to receive keystrokes
in OnKeyDown(). My control is hosted in a MDI form.

Originally my control inherited from UserControl, but then the call to
this.Focus() returned false and no keypresses were received. The I
changed it to inherit from Control and everything works as expected.

Why doesn't it work when I inherit from UserControl?

thanks,
Michael
Kevin Spencer - 19 Oct 2007 13:26 GMT
UserControl is a container Control, which is designed to host other Controls
in a composite form.

Signature

HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

> Hi,
>
[quoted text clipped - 10 lines]
> thanks,
> Michael
milund - 22 Oct 2007 08:36 GMT
So it is in this case correct to inherit from control - the reason for
inheriting from a usercontrol is simply that is what I was given by a
wizard I ran, so I never gave it mouch thought until I ran into
problems ;-)

Thanks for the answer.
Michael

> UserControl is a container Control, which is designed to host other Controls
> in a composite form.
[quoted text clipped - 22 lines]
>
> - Vis tekst i anf?rselstegn -

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.