private void FocusFirstTabIndex(Control container) { // init search result varialble Control searchResult = null; // find the control with the lowest tab index foreach (Control control in container.Controls) { if (control.CanFocus && (searchResult == null || control.TabIndex < searchResult.TabIndex)) { searchResult = control; } } // check if anything searchResult if (searchResult != null) { // focus found control searchResult.Focus(); } else { // focus the container container.Focus(); } }
C#:设置焦点在最小的TabIndex控件上,布布扣,bubuko.com
原文:http://www.cnblogs.com/eastson/p/3796486.html