从文本框中将焦点设置到一个按钮? [英] Setting focus to a button from from text box?

查看:204
本文介绍了从文本框中将焦点设置到一个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个文本框和按钮的窗体上。

I have a few text boxes and buttons on my form.

让我们说txtBox1旁边btnSubmit1,
txtBox2旁边btnSubmit2,
txtBox3毗邻btnSubmit3。

Lets say txtBox1 is next to btnSubmit1, txtBox2 is next to btnSubmit2, txtBox3 is next to btnSubmit3.

如何设置重点btnSubmit3当用户开始输入txtBox3东西。
这意味着.....如果用户键入的文本框,程序会知道,当用户preSS回车键射击哪个按钮。

How can I set the focus on btnSubmit3 when the user starts to type something in txtBox3. Meaning..... if a user type in a text box the program will know what button to fire when the user press the enter key.

推荐答案

如果您使用的是面板上,你应该能够设置一个defaultbutton。我不确定是否在汇入作业形式取胜的应用程序或Web窗体应用程序,但是这是你应该如何与Web窗体做到这一点:

If you use a panel, you should be able to set a defaultbutton. I´m not sure if it´s an win forms application or a web forms application, but this is how you should do it with web forms:

<asp:Panel id="panel1" runat="server" DefaultButton="Button1">
   <asp:TextBox id="textbox1" runat="server" />
   <asp:Button id="Button1" runat="server" Text="Button 1" />
</asp:Panel>

<asp:Panel id="panel2" runat="server" DefaultButton="Button2">
   <asp:TextBox id="textbox2" runat="server" />
   <asp:Button id="Button2" runat="server" Text="Button 2" />
</asp:Panel>

<asp:Panel id="panel3" runat="server" DefaultButton="Button3">
   <asp:TextBox id="textbox3" runat="server" />
   <asp:Button id="Button3" runat="server" Text="Button 3" />
</asp:Panel>

这篇关于从文本框中将焦点设置到一个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆