I have a simple and old windows forms app with a MenuStrip and ContextMenuStrip and I need that the TAB key doesn’t iterate thru the items, it has to be just the arrow keys.
I’ve tried setting TabStop = True but it doesn’t seem to affect the controls.
Any ideas how I could do this easily?
I tried setting TabStop both in designer and code, both true and false on both controls MenuStrip and ContextMenuStrip but they do not seem to have any effect. Also set TabIndex for menustrip to 0 to see if that made any difference but no.
I also tried this, but when I’m navigating with arrows in contextMenuStrip, and then hit tab it doesn’t seem enter this method, it only enters the method when I hit tab in the top menu strip and not all items (those without submenus)
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Tab && (this.ActiveControl == this.menuStrip1 || this.ActiveControl == this.contextMenuStrip1))
{
return true;
OR:
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(Form1_KeyDown);
And then in Keydown, e.SuppressKeyPress = true;
Nothing changes the behavior inside the ContextMenuStrip…
Pdmm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2