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();
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-21
  • 2022-12-23
  • 2022-02-11
  • 2021-11-13
  • 2021-06-21
  • 2021-09-26
相关资源
相似解决方案