Center controls in Tabcontrol

How can one focus controls when a tabitem is selected in a tabcontrol?

0


a source to share


2 answers


You have to capture the TabControl selection changed event and within it where you focus the desired control. As well as



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

      

+1


a source


Not sure if I understand what you are 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?
}

      

+1


a source







All Articles