Je suis perdu en appelant une fonction quand une deuxième touche est pressée. J'ai utilisé l'événement KeyDown pour mes boutons. Et KeyDown appellera une fonction qui va vérifier ce bouton. Mon problème est après avoir vérifié ce bouton, l'utilisateur doit appuyer sur une autre touche Entrée ou barre d'espace pour passer aux données suivantes.C# Appeler une fonction quand une deuxième touche est pressée
Ceci est pour mon radiobutton1 événement keyDown
private void btn1_KeyDown(object sender, KeyEventArgs e)
{
btn1.BackColor = Color.Blue;
checkAns(btn1.Text, btn1);
}
Ceci est ma fonction checkAns qui va vérifier le bouton sélectionné
private void checkAns (string ansText, RadioButton rdo)
{
var row = dTable.Rows[currentRow];
var ans = row["ANSWER"].ToString();
if (ansText == ans)
{
rdo.BackColor = Color.Green;
correctAdd();
//MessageBox.Show("Correct");
}
else
{
rdo.BackColor = Color.Red;
wrongAdd();
//MessageBox.Show("Wrong. Answer is" + " \n " + ans);
}
nextEnter (------); //Here I'm not sure how to call the another keydown/keypress event or value of the enter key
}
Ceci est ma fonction nextEnter
private void nextEnter(------) //Also at this part.
{
if (------ == Keys.Enter) //And here.
currentRow++;
currentNo++;
remain--;
nextRow();
}
Vous pouvez passer la propriété 'KeyCode' de votre' KeyEventArgs' de 'btn1_KeyDown' à' checkAns' et ensuite 'nextEnter'. – MetaColon
@MetaColon, désolé je ne comprends pas. S'il vous plaît, corrigez-moi. le code clé (entrée), c'est-à-dire l'objet? aux checkans? –