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 / Windows Forms / WinForm Controls / March 2005

Tip: Looking for answers? Try searching our database.

Panel and custom control Key events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peder Y - 26 Feb 2005 12:49 GMT
1) How can I make a Panel fire Key events?

Neither overriding the OnKeyUp event nor somePanel.KeyUp += new
KeyEventHandler(somePanel_KeyUp) seems to work.

2) What would be the procedure for doing this on a Control derived control?

Thanks!

- Peder -
Andrew Smith \(Infragistics\) - 26 Feb 2005 20:16 GMT
A panel control doesn't take focus - only the control with the input focus
will receive key events. For example, if your panel contains a textbox and
it is focused, then the key events of the textbox will be invoked - the same
would go for any control that has the focus.

> 1) How can I make a Panel fire Key events?
>
[quoted text clipped - 7 lines]
>
> - Peder -
Peder Y - 26 Feb 2005 23:14 GMT
I figured out that a custom control need to call the Focus() function
for key events to fire.

Now, the strange thing that happens is that the KeyDown event does not
fire when the arrow keys or DEL is pressed. Is this  the way it's
supposed to be?

Thanks!

- Peder -

> 2) What would be the procedure for doing this on a Control derived control?
>
> Thanks!
>
> - Peder -
Andrew Smith \(Infragistics\) - 27 Feb 2005 21:07 GMT
Like I said in my response to your original email, the control with the
input focus receives the key messages. With regards to this post, override
IsInputKey and return true for the keys that are considered input for the
control.

>I figured out that a custom control need to call the Focus() function for
>key events to fire.
[quoted text clipped - 13 lines]
>>
>> - Peder -
Peder Y - 24 Mar 2005 20:16 GMT
...can one in a similar manner override something to make a panel
receive focus?

Andrew Smith (Infragistics) wrote:
> Like I said in my response to your original email, the control with the
> input focus receives the key messages. With regards to this post, override
[quoted text clipped - 18 lines]
>>>
>>>- Peder -
Andrew Smith \(Infragistics\) - 27 Mar 2005 20:22 GMT
You could use the SetStyle(ControlStyles.Selectable, true) method but I'm
curious as to why you would want to do that with a panel? I mean what is the
point of having a container control receive focus? When a child control (or
any other control for that matter) get focus, you will still not receive key
events on the container.

> ...can one in a similar manner override something to make a panel receive
> focus?
[quoted text clipped - 22 lines]
>>>>
>>>>- Peder -
Peder Y - 28 Mar 2005 22:54 GMT
...because I draw stuff using a Panel as a canvas. When I click the
panel, my graphical objects get "selected", meaning they redraw
themselves as selected. I can move them around and resize them with the
mouse. I want to be able to move them around using the arrow keys, and
resize them using ctrl+arrow as well. Maybe there's a better approach to
this like creating my own ScrollableControl? I just wouldn't go there if
I didn't have to.

- Peder -

Andrew Smith (Infragistics) wrote:
> You could use the SetStyle(ControlStyles.Selectable, true) method but I'm
> curious as to why you would want to do that with a panel? I mean what is the
[quoted text clipped - 29 lines]
>>>>>
>>>>>- Peder -

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.