views:

301

answers:

2

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

+1  A: 

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?
}
Nick Spacek
+1  A: 

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