Entwickler-Ecke

WinForms - Tastenkombination auf Form abfangen


erfahrener Neuling - Mi 06.04.16 13:45
Titel: Tastenkombination auf Form abfangen
Hallo,

ich möchte die Tastenkombination STRG + R abfangen.
Das hier funktioniert nicht

C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
if (e.KeyCode == (Keys.Control | Keys.R))
{
  //funktioniert nicht
}

if (e.KeyCode == (Keys.Control & Keys.R))
{
       //funzt auch nicht
}
Bitte um schnelle und einfache Hilfe.

Danke im Vorraus!


Christian S. - Mi 06.04.16 13:47

Schau Dir nochmal die Eigenschaften des Parameters e an ;-)


erfahrener Neuling - Mi 06.04.16 13:52

Ok danke mal wieder :)

Die richtige Lösung war jetzt

C#-Quelltext
1:
if (e.Control & e.KeyCode == Keys.R) {}                    
Das hatte ich vorhin auch schon, aber da hatte ich die KeyPreview noch auf false.

Wieder was neues dazu gelernt :zustimm: