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

  • Thread starter Thread starter Andrew Backer
  • Start date Start date
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
 
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
 
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
 
Back
Top