Click here to Skip to main content
15,892,737 members
Home / Discussions / C#
   

C#

 
QuestionDo you use obfuscator? Pin
Froddo8-Feb-19 7:01
Froddo8-Feb-19 7:01 
AnswerRe: Do you use obfuscator? Pin
Gerry Schmitz8-Feb-19 10:40
mveGerry Schmitz8-Feb-19 10:40 
AnswerRe: Do you use obfuscator? Pin
Eddy Vluggen11-Feb-19 2:47
professionalEddy Vluggen11-Feb-19 2:47 
GeneralRe: Do you use obfuscator? Pin
Froddo12-Feb-19 6:52
Froddo12-Feb-19 6:52 
GeneralRe: Do you use obfuscator? Pin
Wastedtalent13-Feb-19 21:07
professionalWastedtalent13-Feb-19 21:07 
AnswerRe: Do you use obfuscator? Pin
BillWoodruff16-Feb-19 14:39
professionalBillWoodruff16-Feb-19 14:39 
GeneralRe: Do you use obfuscator? Pin
Froddo18-Feb-19 6:56
Froddo18-Feb-19 6:56 
AnswerRe: Do you use obfuscator? Pin
Member 1412742220-Feb-19 6:33
Member 1412742220-Feb-19 6:33 
GeneralRe: Do you use obfuscator? Pin
Froddo22-Feb-19 9:00
Froddo22-Feb-19 9:00 
QuestionDGVPrinter how to print Logo and a frame in the text Pin
Member 141432997-Feb-19 7:34
Member 141432997-Feb-19 7:34 
AnswerRe: DGVPrinter how to print Logo and a frame in the text Pin
OriginalGriff7-Feb-19 21:21
mveOriginalGriff7-Feb-19 21:21 
GeneralRe: DGVPrinter how to print Logo and a frame in the text Pin
Member 141432998-Feb-19 3:04
Member 141432998-Feb-19 3:04 
GeneralRe: DGVPrinter how to print Logo and a frame in the text Pin
OriginalGriff8-Feb-19 3:10
mveOriginalGriff8-Feb-19 3:10 
QuestionDisable focus in button with arrow right left up down Pin
Member 114269867-Feb-19 2:29
Member 114269867-Feb-19 2:29 
AnswerRe: Disable focus in button with arrow right left up down Pin
Ralf Meier7-Feb-19 2:41
mveRalf Meier7-Feb-19 2:41 
GeneralRe: Disable focus in button with arrow right left up down Pin
Member 114269867-Feb-19 2:53
Member 114269867-Feb-19 2:53 
GeneralRe: Disable focus in button with arrow right left up down Pin
Richard MacCutchan7-Feb-19 4:40
mveRichard MacCutchan7-Feb-19 4:40 
GeneralRe: Disable focus in button with arrow right left up down Pin
Richard MacCutchan7-Feb-19 6:10
mveRichard MacCutchan7-Feb-19 6:10 
AnswerRe: Disable focus in button with arrow right left up down Pin
Alan N7-Feb-19 5:22
Alan N7-Feb-19 5:22 
Some of this key handling stuff is not obvious and I'm no expert! In this case you have to tell the Button control not to give the arrow keys special handling. To do this override the IsInputKey method.

My example also overrides OnKeyDown to make buttons of this class move in response to the arrow keys. I imagine that you would want to have that functionality in a separate KeyDown event handler.


C#
public class AnnoyingButton : Button {

  protected override bool IsInputKey(Keys keyData) {
    return keyData == Keys.Up || keyData == Keys.Down ||
           keyData == Keys.Left || keyData == Keys.Right;
  }

  protected override void OnKeyDown(KeyEventArgs args) {
    Point newLocation = Location;

    switch (args.KeyCode) {
      case Keys.Right:
        newLocation.Offset(1, 0);
        Location = newLocation;
        break;
      case Keys.Left:
        newLocation.Offset(-1, 0);
        Location = newLocation;
        break;
      case Keys.Down:
        newLocation.Offset(0, 1);
        Location = newLocation;
        break;
      case Keys.Up:
        newLocation.Offset(0, -1);
        Location = newLocation;
        break;
      default:
        base.OnKeyDown(args);
    }
  }
}


I did have a good link about this stuff but as I'm moving computer I don't know where it is at the moment.

EDIT: HERE IS THAT LINK
Exploring Secrets of .NET Keystroke Handling[^]

Alan.

modified 11-Feb-19 7:24am.

GeneralRe: Disable focus in button with arrow right left up down Pin
BillWoodruff9-Feb-19 19:56
professionalBillWoodruff9-Feb-19 19:56 
AnswerRe: Disable focus in button with arrow right left up down Pin
Gerry Schmitz7-Feb-19 6:22
mveGerry Schmitz7-Feb-19 6:22 
GeneralRe: Disable focus in button with arrow right left up down Pin
BillWoodruff10-Feb-19 9:07
professionalBillWoodruff10-Feb-19 9:07 
QuestionC# GUI for plotting real time MPU(acceleration) scensors Pin
Member 141421336-Feb-19 7:23
Member 141421336-Feb-19 7:23 
AnswerRe: C# GUI for plotting real time MPU(acceleration) scensors Pin
Gerry Schmitz6-Feb-19 8:01
mveGerry Schmitz6-Feb-19 8:01 
GeneralRe: C# GUI for plotting real time MPU(acceleration) scensors Pin
Member 141421336-Feb-19 8:41
Member 141421336-Feb-19 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.