获取焦点/保持选定的文本框和按钮 | C#
Get Focus / maintain Selected a TextBox and a Button | C#
我正在尝试像这张照片一样获得焦点:
[
-
所以我可以选择一个文本框并写入它,同时将焦点放在接受按钮上
private void frm_redimensionar_Load(object sender, EventArgs e)
{
if (frm_MonoPaint.Exporto == " ")
{
num_amplada.Value = 32;
num_alcada.Value = 32;
}
num_amplada.Focus(); //
bttn_enviar.Focus(); //
}
private void bttn_cancelar_Click(object sender, EventArgs e)
{
Close();
}
private void bttn_enviar_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
public int redAlcada()
{
return Convert.ToInt32(num_alcada.Value);
}
public int redAmplada()
{
return Convert.ToInt32(num_amplada.Value);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Escape)
{
this.Close();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
好吧,我找到了我自己问题的答案。
""this."" AcceptButton = yourbuttonname;
这个 post 的标题不好,但是当你不知道你在做什么时,它就会发生。 .-.
我正在尝试像这张照片一样获得焦点:
[
所以我可以选择一个文本框并写入它,同时将焦点放在接受按钮上
private void frm_redimensionar_Load(object sender, EventArgs e)
{
if (frm_MonoPaint.Exporto == " ")
{
num_amplada.Value = 32;
num_alcada.Value = 32;
}
num_amplada.Focus(); //
bttn_enviar.Focus(); //
}
private void bttn_cancelar_Click(object sender, EventArgs e)
{
Close();
}
private void bttn_enviar_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
public int redAlcada()
{
return Convert.ToInt32(num_alcada.Value);
}
public int redAmplada()
{
return Convert.ToInt32(num_amplada.Value);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Escape)
{
this.Close();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
好吧,我找到了我自己问题的答案。
""this."" AcceptButton = yourbuttonname;
这个 post 的标题不好,但是当你不知道你在做什么时,它就会发生。 .-.