Focus the controls in a Tabcontrol

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 12:54:38

问题


How can focus the controls when select a tabitem in a tabcontrol?


回答1:


You should capture the Selection changed event of the TabControl and inside that you focus the control you need. Just as

private void TabControl1_SelectionChanged(object sender, EventArgs e)
{
    control1.Focus();
}



回答2:


Not sure I understand what you're asking completely, but you probably want to capture the SelectionChanged event for the TabControl:


public Window1()
{
  InitializeComponent();

  TabControl1.SelectionChanged += TabControl1_SelectionChanged;
}

private void TabControl1_SelectionChanged(object sender, EventArgs e)
{
  TabItem item = (TabItem)TabControl1.SelectedItem;
  // Find the first control in the TabItem content and focus it?
}


来源:https://stackoverflow.com/questions/892393/focus-the-controls-in-a-tabcontrol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!