在 Visual Studio 2010 中控制 Tab 键顺序
有没有一种简单的方法可以在 Visual Studio 表单设计器中更改复杂表单上控件的选项卡顺序。
我知道我可以选择 Tab Order 模式,它会向我显示所有控件及其选项卡索引,但是在复杂的表单中间添加新控件并且必须再次重新选择表单上的每个控件是一件很痛苦的事情设置新的 Tab 键顺序。我经常发现我不小心错过了一个控制,因此必须重新开始。
我在 MSDN 上读到,至少应该可以按住 Ctrl 键单击要开始新控件重新排序的位置之前的控件,然后单击之后的每个控件来设置新的选项卡顺序,但我不能让它发挥作用。按住 Ctrl 键单击前一个控件只会将该控件设置为 Tab Index 0,这样它就成为整个窗体上新的第一个控件。
我来自delphi背景,在delphi中,当编辑控件选项卡顺序时,您会看到一个对话框,显示表单上所有控件的列表,您可以从列表中选择一个控件并将其在列表中向上或向下移动。对于简单的更改(例如交换选项卡顺序或在表单中间添加新控件)要容易得多。 也许我错过了一些东西,并且可以轻松做到这一点。如果 Visual Studio 中不可用,是否有一个模仿 Delphi 功能的插件。
问候 布莱恩
Is there an easy way of changing the tab order of controls on a complicated form in the Visual Studio forms designer.
I know that I can select the Tab Order mode and it shows me all the controls with their tab index, but it is such a pain to add a new control in the middle of a complicated form and have to reselect EVERY control on the form again to set the new tab order. I often find that I have accidentally missed a control and so have to do it all over again.
I read on MSDN that it should at least be possible to Ctrl-Click on the control previous to where I want to start the new control reordering and then click on each contol after that to set the new the tab order, but I can't get that to work. Ctrl-Clicking the previous control just sets that one to Tab Index 0 and so that becames the new first control on the whole form.
I come from a delphi background and in delphi when editing the control tab order you get a dialog showing a list of all the controls on the form and you can select a control from the list and move it up or down the list. Much easier for a simple change like swapping tab order or adding a new control in to the middle of a form.
Perhaps I am missing something, and it is possible to do this easily. If not available in Visual studio is there an add in that mimics the delphi functionality.
Regards
Brian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果添加新控件并为其指定使用的 Tab 键顺序值,Visual Studio 将自动替换其余部分。两个控件将具有相同的 Tab 键顺序,但它会起作用。
If you add a new control and give it a tab order value that is used, Visual Studio will automatically replace the rest. Both controls will have the same tab order, but it will work.
如果您有太多控制权,则更改 Tab 键顺序的最简单方法是,只需以文本模式打开您的
PROJECT.RC
文件并找到配置对话框的位置...例如:Between
BEGIN
和END
您的控件按其 TAB 顺序排序。只需将行移动到您想要 TAB ORDER 的位置即可。只需交换前两行,取消按钮就会像 Tab 键顺序 1 一样。The easiest way to change your tab order if you have too many control, simply open your
PROJECT.RC
file in text mode and locate where your dialog is configure.... for example:Between
BEGIN
andEND
your controls are ORDERED by their TAB ORDER. Simply move the line corresponding to where you want your TAB ORDER. Simply SWAP the first two lines and it will be Cancel button as tab order 1.正如您指出的那样,重新排列表单不是一个选择,您可以考虑使用 CodeProject 中的老忠实用户: Windows 窗体的自动运行时选项卡顺序管理。它有点过时(例如没有强类型泛型集合),但它工作得很好。
项目中的
TabOrderManager.cs
可以单独编译,您(我)不需要配套的IExtenderProvider
和测试项目的所有用具。如果表单需要更改,您只需添加新控件,并在
InitializeComponent();
下面添加一个像Hope 它适合您的调用。
As you indicate that rearranging the forms is not an option you may consider using an old faithful from CodeProject: Automatic Runtime Tab Order Management for Windows Forms. It's a bit outdated (no strong typed generic collections for instance) but it works pretty well.
The
TabOrderManager.cs
from the project can be compiled on its own, you (I) don't need all the paraphernalia of the companionIExtenderProvider
and the test project.If a form needs change you could just add new controls and below
InitializeComponent();
add a call likeHope it suits you.