フォームにいくつかのコントロールがあるので、フォームでイベントを読み取って作成します。これを押すENTERと、フォーカスを別のコントロールに変更できます。コードは次のとおりです。
private void frSeleccionEL_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Control nextControl = this.GetNextControl(ActiveControl, !e.Shift);
if (nextControl != null)
{
e.Handled = true;
if (!(nextControl is Label))
{
nextControl.Focus();
}
else //the next control is currently a label
{
nextControl = this.GetNextControl(ActiveControl, true);
while (nextControl != null)
{
nextControl.Focus();
if (!(nextControl is Label))
{
break;
}
nextControl = this.GetNextControl(ActiveControl, true);
}
}
}
}
}
機能していないテキストボックスには、数字のみのコードがあります。コードは次のとおりです。
private void txtLocal_KeyPress(object sender, KeyPressEventArgs e)
{
//Para obligar a que sólo se introduzcan números
if (Char.IsDigit(e.KeyChar))
{
e.Handled = false;
}
else
{
if (Char.IsControl(e.KeyChar)) //permitir teclas de control como retroceso
{
e.Handled = false;
}
else
{
//el resto de teclas pulsadas se desactivan
e.Handled = true;
}
}
}
私の問題は、このコントロールのキープレスイベントが発生しないため、ENTERこのコントロールを押しても何も起こらないことです。ENTER
コントロールを削除して作り直しましたが、問題は残ります。
何が悪いのかわかりません。