C# Geeignetes Key - Ereignis |
InformaTiger
Tripel-As
Dabei seit: 19.02.2013
Beiträge: 228
Herkunft: Südtirol
|
|
|
02.04.2013 12:18 |
|
|
|
Nimm KeyDown oder KeyUp (gibt noch KeyPress, das reagiert aber nicht auf Pfeiltasten).
Also entweder dann Ereignis der aktiven Komponente auswerten, oder so:
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
|
private void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyCode.ToString());
} |
|
KeyPreview sorgt dafür, dass Form1 das Ereignis mitgeteilt bekommt (auch wenn du z.B. in eine TextBox schreibst).
__________________ Syntax Highlighting fürs Board (Link)
|
|
02.04.2013 13:09 |
|
|
InformaTiger
Tripel-As
Dabei seit: 19.02.2013
Beiträge: 228
Herkunft: Südtirol
|
|
Ich habe das gerade so versucht, leider wechselt der Computer nur zwischen den Buttons...
vielleicht ist ja bei meinem Switch- Code etwas falsch.
Lg
InformaTiger
__________________ Why do Java developers wear glasses? Because they can't C#
|
|
02.04.2013 13:18 |
|
|
InformaTiger
Tripel-As
Dabei seit: 19.02.2013
Beiträge: 228
Herkunft: Südtirol
|
|
Nun habe ich ein weiteres Problem...
Gibt es eine Eigenschaft die einem Panel sagt es soll keine anderen Steuerelemente annehmen?
Lg
InformaTiger
__________________ Why do Java developers wear glasses? Because they can't C#
|
|
02.04.2013 15:10 |
|
|
InformaTiger
Tripel-As
Dabei seit: 19.02.2013
Beiträge: 228
Herkunft: Südtirol
|
|
Ich habe leider keine Ahnung ob und wie das geht
Lg
InformaTiger
__________________ Why do Java developers wear glasses? Because they can't C#
|
|
02.04.2013 16:10 |
|
|
|
ich meinte etwa so:
int eigentlichX = button1.Location.X + panel1.Location.X;
Bei mir steht aber auch nicht -1;-1 in Button1.Location, sondern die relative Position im Panel.
Tauchen die Koordinaten -1;-1 zur Entwurfs- oder Laufzeit auf?
Verstehe ich das eigentlich richtig, dass du Buttons zum Anzeigen von Bildern zweckentfremdest? Dafür gibt es eigentlich die PictureBox.
__________________ Syntax Highlighting fürs Board (Link)
|
|
02.04.2013 16:23 |
|
|
InformaTiger
Tripel-As
Dabei seit: 19.02.2013
Beiträge: 228
Herkunft: Südtirol
|
|
Zu den Panels: Ich verwende die Panels nur als Orientierungspunkt für den Benutzer (Weißer Hintergrund, FixedSingle Border).
Zu den Koordinaten: Die Koordinaten tauchen in der Entwurfszeit bei den Buttons auf.
Aber: Ich glaube der Code den du hier geschrieben hast macht für mich in diesem Zusammenhang wenig Sinn...
code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
|
if ((btn3.Location.X == pnl5.Location.X) && (btn3.Location.Y == pnl5.Location.Y) && (btn15.Location.X == pnl1.Location.X) && (btn15.Location.Y == pnl1.Location.Y) && (btn11.Location.X == pnl9.Location.X) && (btn11.Location.Y == pnl9.Location.Y) && (btn5.Location.X == pnl13.Location.X) && (btn5.Location.Y == pnl13.Location.Y) && (btn6.Location.X == pnl2.Location.X) && (btn6.Location.Y == pnl2.Location.Y) && (btn1.Location.X == pnl6.Location.X) && (btn1.Location.Y == pnl6.Location.Y) && (btn12.Location.X == pnl10.Location.X) && (btn12.Location.Y == pnl10.Location.Y) && (btn13.Location.Y == pnl10.Location.Y) && (btn9.Location.X == pnl14.Location.X) && (btn9.Location.Y == pnl14.Location.Y) && (btn14.Location.X == pnl3.Location.X) && (btn14.Location.Y == pnl3.Location.Y) && (btn2.Location.X == pnl7.Location.X) && (btn2.Location.Y == pnl7.Location.Y) && (btn10.Location.X == pnl11.Location.X) && (btn10.Location.Y == pnl11.Location.Y) && (btn16.Location.X == pnl15.Location.X) && (btn16.Location.Y == pnl15.Location.Y) && (btn8.Location.X == pnl4.Location.X) && (btn8.Location.Y == pnl4.Location.Y) && (btn13.Location.X == pnl8.Location.X) && (btn13.Location.Y == pnl8.Location.Y) && (btn4.Location.X == pnl12.Location.X) && (btn4.Location.Y == pnl12.Location.Y) && (btn7.Location.X == pnl16.Location.X) && (btn7.Location.Y == pnl16.Location.Y))
{
MessageBox.Show("Super der Code zum nächsten Level ist: GjBqa8");
Level2 aAnzeigeObjekt = new Level2();
aAnzeigeObjekt.Show();
this.Close();
}
else
{
MessageBox.Show("Leider, nicht richtig!");
} |
|
Lg
InformaTiger
__________________ Why do Java developers wear glasses? Because they can't C#
|
|
02.04.2013 16:38 |
|
|
|
Eine Zeile mit 1351 Zeichen?!
Und dann noch Indizes, die wild durcheinander gehen.
Das muss auch anders gehen, ich rate zu einem Array von Anzeigeelementen.
Dürfte jetzt ein gewisser Aufwand sein, das alles nochmal umzustellen, zahlt sich aber durch den einfacheren Umgang wieder aus.
Hast 'ne Mail.
__________________ Syntax Highlighting fürs Board (Link)
|
|
02.04.2013 16:50 |
|
|
InformaTiger
Tripel-As
Dabei seit: 19.02.2013
Beiträge: 228
Herkunft: Südtirol
|
|
Naja, damit kenne ich mich leider gar nich aus... oder ich versteh nicht was du meinst.
Lg
InformaTiger
__________________ Why do Java developers wear glasses? Because they can't C#
|
|
02.04.2013 17:01 |
|
|
|