我希望用户能够通过点击Keys.Enter
,Keys.Up
,Keys.Down
在文本框和按钮之间移动。有没有类似this.SelectedItem = TxtBoxName
的方法?
private void TxtBoxName_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if(TextIsEmpty(TxtBoxDebt.Text))
{
//switch to TxtBoxDebt
}
else
{
AssignNewPerson();
}
}
if (e.KeyCode == Keys.Down)
{
//switch to TxtBoxDebt
}
}
private void TxtBoxDebt_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
AssignNewPerson();
}
else if (e.KeyCode == Keys.Up)
{
//switch to TxtBoxName
}
else if(e.KeyCode == Keys.Down)
{
//switch to TxtBoxNote
}
}
private void TxtBoxNote_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
AssignNewPerson();
}
else if (e.KeyCode == Keys.Up)
{
//switch to TxtBoxDebt
}
else if (e.KeyCode == Keys.Down)
{
//switch to BtnAssign
}
}
1条答案
按热度按时间dw1jzc5e1#
我认为您正在寻找Focus()方法,例如: