Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a specific TabItem gain focus on a TabControl without click event?

How can I tell my TabControl to set the focus to its first TabItem, something like this:

PSEUDO-CODE:

((TabItem)(MainTabControl.Children[0])).SetFocus();
like image 708
Edward Tanguay Avatar asked Aug 04 '09 12:08

Edward Tanguay


2 Answers

How about this?

MainTabControl.SelectedIndex = 0;
like image 130
Martin Liversage Avatar answered Sep 21 '22 03:09

Martin Liversage


this.tabControl1.SelectedTab = this.tabControl1.TabPages["tSummary"];

I've found it's usually a best practice to name your tabs and access it via the name so that if/when other people (or you) add to or subtact tabs as part of updating, you don't have to go through your code and find and fix all those "hard coded" indexes. hope this helps.

like image 39
Brian Avatar answered Sep 22 '22 03:09

Brian