Up/Down keys aren't recognized when button in focus

G

Guest

Hi again,
With much help, I've finally gotten the Tab key to be recognized when a
textbox is in focus, but now I'm having trouble with the up/down keys when
they're focused on a custom button (on KeyDown, when I ask to show keyCode,
nothing happens (except for Enter) so the focus goes to some textboxes that
should never receive focus).
I can think of 3 options, but don't know how to do any of them:

1) Say that these textboxes should never receive focus.

2) I changed my button to a system button and tried the same thing as I did
for the Tab key, but I hate how the system highlights the button - So, change
the button so that it does get that background highlight (but does have the
dotted rectangle when in focus).

3) Program into my code for the custom button that it should recognize the
up/down keys.

Thanks again!
Mel

This is the code for my button (from an example in the MS Visual C# .NET
Step by Step book):

using System;
using System.Windows.Forms;
using System.Drawing;

namespace ToleranceUnits
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Toggle3x : CheckBox
{
public Toggle3x()
{
//
// TODO: Add constructor logic here
//

this.Appearance = Appearance.Button;
this.gmcm = "gm-cm";
this.gmin = "gm-in";
this.ozin = "oz-in";
this.gmcmColor = Color.Gold;
this.gminColor = Color.Blue;
this.ozinColor = Color.Fuchsia;

}

private string gmcm;
private string gmin;
private string ozin;
private Color gmcmColor;
private Color gminColor;
private Color ozinColor;

public string Gmcm
{
get
{
return this.gmcm;
}
set
{
this.gmcm = value;
}
}
public string Gmin
{
get
{
return this.gmin;
}
set
{
this.gmin = value;
}
}
public string Ozin
{
get
{
return this.ozin;
}
set
{
this.ozin = value;
}
}
public Color GmcmColor
{
get
{
return this.gmcmColor;
}
set
{
this.gmcmColor = value;
}
}
public Color GminColor
{
get
{
return this.gminColor;
}
set
{
this.gminColor = value;
}
}
public Color OzinColor
{
get
{
return this.ozinColor;
}
set
{
this.ozinColor = value;
}
}
}
}
 
G

Guest

Nevermind - 2 seconds after I posted this I realized I could do an
Focus-Enter Event for the textboxes that I didn't want entered.
Mel
 

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