How to make a tab control handle ctrl+tab, instead of the MDI parent doing it?

A

Andrew Backer

Hello,

Is there any way to make the tab control, when a control within it's bounds
has focus, respond to control+tab? I am hoping for a codeless solution,
but if one is not possible that is fine too.

This is taking place inside an MDI application, so currently it is changing
the selected window. My simple searches have turned up nothing, and MS doesn't
provide an easy way to search this group :(

Thanks,

//Andrew
 
B

Brendon Bezuidenhout

Andrew,

Have you tried looking at the Protected Overrides Function ProcessCmdKey in
the form; something like:

<code>
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg,
System.Windows.Forms.Keys keyData)
{
if (keyData == (Keys.ControlKey + Keys.Enter))
{
if (Control1.Focused)
{
//Do your code to be handled for the control
}
return true;
//This is needed or the form will think Control + Enter has been hit twice
}
return base.ProcessCmdKey(msg, keyData);
}
</code>

Brendon
 
A

Andrew Backer

Thank you, kind Sir!!

That is _exactly_ the method I was looking for, and my ctrl+<shift>+tab logic
is now happily implemented. I was stuck here looking for an event, or something
like "keypress". I am a bit surprised that this isn't out there somewhere
already, as an example, since it seems like something many peopel would need.
Maybe everyone just used 3rd party ctrls, like we should ;)

//Andrew
 

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