当前位置: 首页>>代码示例>>C#>>正文


C# TabControl.SelectTab方法代码示例

本文整理汇总了C#中System.Windows.Forms.TabControl.SelectTab方法的典型用法代码示例。如果您正苦于以下问题:C# TabControl.SelectTab方法的具体用法?C# TabControl.SelectTab怎么用?C# TabControl.SelectTab使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TabControl的用法示例。


在下文中一共展示了TabControl.SelectTab方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ISelectionProviderEventTest

		public void ISelectionProviderEventTest ()
		{
			TabControl tc = new TabControl ();
			TabPage tp1 = new TabPage ();
			TabPage tp2 = new TabPage ();
			tc.Controls.Add (tp1);
			tc.Controls.Add (tp2);
			Form.Controls.Add (tc);
			
			IRawElementProviderSimple provider
				= ProviderFactory.GetProvider (tc);

			ISelectionProvider selectionProvider
				= provider.GetPatternProvider (
					SelectionPatternIdentifiers.Pattern.Id) as ISelectionProvider;
			Assert.IsNotNull (selectionProvider, "Not returning SelectionPatternIdentifiers.");

			tc.SelectTab (0);

			// Case 1: Select currently selected tab
			bridge.ResetEventLists ();
			tc.SelectTab (0);
			Assert.AreEqual (0, bridge.AutomationEvents.Count,
			                 "EventCount after selecting selected tab");

			// Case 2: Select different tab
			bridge.ResetEventLists ();
			tc.SelectTab (1);
			Assert.AreEqual (1,
			                 bridge.GetAutomationPropertyEventCount (SelectionPatternIdentifiers.SelectionProperty),
			                 "EventCount after selecting new tab");
			
			IRawElementProviderSimple[] pageProviders
				= selectionProvider.GetSelection ();
			Assert.IsNotNull (pageProviders, "Null selection returned");
			Assert.AreEqual (1, pageProviders.Length,
			                 "Less/More than one selected page returned");

			IRawElementProviderSimple child
				= ((IRawElementProviderFragmentRoot) provider)
					.Navigate (NavigateDirection.FirstChild);
			Assert.IsNotNull (child, "First child is null");

			child = ((IRawElementProviderFragment) child)
					.Navigate (NavigateDirection.NextSibling);
			Assert.IsNotNull (child, "Second child is null");
			
			Assert.AreEqual (child, pageProviders[0],
			                 "Selected child and second child aren't equal");

			IRawElementProviderSimple pageProvider = pageProviders[0];
			
			// TODO: flesh this out when we implement TabPageProvider
			Assert.IsNotNull (pageProvider);
		}
开发者ID:mono,项目名称:uia2atk,代码行数:55,代码来源:TabControlProviderTest.cs

示例2: ShowPage

 /// <summary>
 /// 显示指定的page,并使之成为当前page
 /// </summary>
 /// <param name="container"></param>
 /// <param name="page"></param>
 public static void ShowPage(TabControl container,TabPage page)
 {
     if (!container.Contains(page))
     {
         container.TabPages.Add(page);
     }
     page.Show();
     container.SelectTab(page);
 }
开发者ID:lijuntao0607,项目名称:InvoicingManagement,代码行数:14,代码来源:TabControlManager.cs

示例3: EntryTemplateManager

        public EntryTemplateManager(IPluginHost host, PwEntryForm form)
        {
            m_host = host;
            this.form = form;
            our_page = new TabPage("Template");
            our_page.AutoScroll = true;

            form_tab_control = get_control_from_form(form, "m_tabMain") as TabControl;
            Debug.Assert(form_tab_control != null);
            form_tab_control.Selecting += main_tabs_control_Selecting;
            _entry_is_template = form.EntryStrings.Get("_etm_template") != null;
            ProtectedString str = form.EntryStrings.Get("_etm_template_uuid");
            entry_is_child = str != null;
            if (entry_is_child)
                child_template_uuid = str.ReadString();
            form.EntrySaving += form_EntrySaving;
            our_page.UseVisualStyleBackColor = true;
            form_tab_control.TabPages.Insert(0, our_page);
            if (entry_is_child || entry_is_template)
                form_tab_control.SelectTab(0);
        }
开发者ID:mitchcapper,项目名称:KPEntryTemplates,代码行数:21,代码来源:EntryTemplateManager.cs

示例4: AddTabControl

 /// <summary>
 /// ��tabcontrol���翨Ƭ��
 /// </summary>
 /// <param name="tc">ָ����tabcontrol</param>
 public static void AddTabControl(TabControl tc, string title, Control c)
 {
     if (dicpage.ContainsKey(title))
     {
         tc.SelectTab(title);
         return;
     }
     TabPage tp = new TabPage(title);
     tp.Name = title;
     dicpage.Add(title, tp);
     tp.Controls.Add(c);
     c.Dock = DockStyle.Fill;
     tc.TabPages.Add(dicpage[title]);
     tc.SelectTab(title);
 }
开发者ID:wyerp,项目名称:DataTransPlantForm,代码行数:19,代码来源:CommonFunction.cs

示例5: ux_tabcontrolMouseDownEvent

        public void ux_tabcontrolMouseDownEvent(TabControl ux_tabcontrolDataview, MouseEventArgs e)
        {
            int clickedTabPage = ux_tabcontrolDataview.SelectedIndex;

            // Attempt to find the tabpage that was clicked...
            for (int i = 0; i < ux_tabcontrolDataview.TabPages.Count; i++)
            {
                if (ux_tabcontrolDataview.GetTabRect(i).Contains(e.Location)) clickedTabPage = i; //MessageBox.Show(ux_tabcontrolDataview.TabPages[i].Text + " : " + e.Location.ToString());
            }

            if (e.Button == MouseButtons.Left)
            {
                // Begin tabpage drag and drop move (if the clicked tab is not
                // the "ux_tabpageDataviewNewTab" tabpage - which is use to add new dataviews)...
                if (ux_tabcontrolDataview.TabPages[clickedTabPage] != ux_tabcontrolDataview.TabPages["ux_tabpageDataviewNewTab"])
                {
                    ux_tabcontrolDataview.DoDragDrop(ux_tabcontrolDataview.TabPages[clickedTabPage], DragDropEffects.Move);
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                // Make the right clicked tabpage the selected tabpage for the control...
                ux_tabcontrolDataview.SelectTab(clickedTabPage);
            }
        }
开发者ID:egacheru,项目名称:G2,代码行数:25,代码来源:UserInterfaceUtils.cs

示例6: ux_tabcontrolDragDropEvent

        public void ux_tabcontrolDragDropEvent(TabControl ux_tabcontrolDataview, DragEventArgs e)
        {
            if (e.AllowedEffect == e.Effect)
            {
                // Convert the mouse coordinates from screen to client...
                System.Drawing.Point ptClientCoord = ux_tabcontrolDataview.PointToClient(new System.Drawing.Point(e.X, e.Y));

                int destinationTabPageIndex = -1;
                int originalTabPageIndex = -1;

                // Attempt to find where the tabpage should be dropped...
                for (int i = 0; i < ux_tabcontrolDataview.TabPages.Count; i++)
                {
            //if (ux_tabcontrolDataview.TabPages[i] == e.Data.GetData(typeof(TabPage))) originalTabPageIndex = i;
            if (ux_tabcontrolDataview.TabPages[i] == e.Data.GetData("System.Windows.Forms.TabPage")) originalTabPageIndex = i;
                    if (ux_tabcontrolDataview.GetTabRect(i).Contains(ptClientCoord)) destinationTabPageIndex = i;
                }

                // Now create a copy of the tabpage that is being moved so that
                // you can remove the orginal and insert the copy at the right spot...
                TabPage newTabPage = new TabPage();
            //newTabPage.Text = ((TabPage)e.Data.GetData(typeof(TabPage))).Text;
            newTabPage.Text = ((TabPage)e.Data.GetData("System.Windows.Forms.TabPage")).Text;
            //newTabPage.Tag = ((TabPage)e.Data.GetData(typeof(TabPage))).Tag;
            newTabPage.Tag = ((TabPage)e.Data.GetData("System.Windows.Forms.TabPage")).Tag;
                ux_tabcontrolDataview.TabPages.Insert(destinationTabPageIndex, newTabPage);
                ux_tabcontrolDataview.SelectTab(destinationTabPageIndex);
                if (originalTabPageIndex < destinationTabPageIndex)
                {
                    ux_tabcontrolDataview.TabPages.RemoveAt(originalTabPageIndex);
                }
                else
                {
                    ux_tabcontrolDataview.TabPages.RemoveAt(originalTabPageIndex + 1);
                }
            }
        }
开发者ID:egacheru,项目名称:G2,代码行数:37,代码来源:UserInterfaceUtils.cs

示例7: showTabPage

 protected bool showTabPage(TabPage tab, int index, TabControl control)
 {
     if(control.TabPages.Contains(tab)) {
         return false;
     }
     control.TabPages.Insert(index, tab);
     control.SelectTab(index);
     return true;
 }
开发者ID:3F,项目名称:vsCommandEvent,代码行数:9,代码来源:EventsFrm.cs

示例8: ux_comboboxCNO_SelectedIndexChanged

        private void ux_comboboxCNO_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            if (ux_comboboxCNO.SelectedIndex != -1)
            {
                string tabOrder = "";
                DataTable userListItems;

                if (_currentCooperatorID.Trim() == _usernameCooperatorID.Trim())
                {
                    // Save user settings...
                    SetAllUserSettings();
                    _sharedUtils.SaveAllUserSettings();
                    // Save the user's list (if the user owns that list)...
                    SaveNavigatorTabControlData(_ux_NavigatorTabControl, int.Parse(_usernameCooperatorID));
                }

                // Get the treeview lists for the currently selected cooperator...
                userListItems = GetUserItemList((int)ux_comboboxCNO.SelectedValue);

                //// If the user is switching back to their own list - go get the tabOrder property...
                //if (cno.ToLower().Trim() == ux_comboboxCNO.SelectedValue.ToString().ToLower().Trim())
                //{
                //    //tabOrder = userSettings[ux_tabcontrolGroupListNavigator.Name, "TabPages.Order"];
                //    tabOrder = _sharedUtils.GetUserSetting(ux_tabcontrolGroupListNavigator.Name, "TabPages.Order", "");

                //    // This is code to handle legacy user settings - pull this out after RC2...
                //    if (!tabOrder.Contains(_pathSeparator))
                //    {
                //        tabOrder = "";
                //    }

                //}
                //else
                //{
                //    tabOrder = "";
                //}

                // Rebuild the Navigator Tab Control with the new user item list...
                _ux_NavigatorTabControl = BuildTabControl(userListItems);
                //_ux_NavigatorTabControl.Select();
                //_ux_NavigatorTabControl.Focus();
                //_ux_NavigatorTabControl.SelectTab("");
                _ux_NavigatorTabControl.SelectTab(0);
                TreeView tv = (TreeView)_ux_NavigatorTabControl.SelectedTab.Controls[_ux_NavigatorTabControl.SelectedTab.Name + "TreeView"];
                if (tv.SelectedNode == null)
                {
                    RestoreActiveNode(tv);
                }

                //if (tv.SelectedNode == null)
                //{
                //    tv.SelectedNode = tv.Nodes[0];
                //}
                //else
                //{
                //    TreeNode currentSelectedNode = tv.SelectedNode;
                //    tv.SelectedNode = null;
                //    tv.SelectedNode = currentSelectedNode;
                //}
                // Save the value of the new currentCooperatorID
                _currentCooperatorID = ux_comboboxCNO.SelectedValue.ToString().Trim();
            }
            else
            {
                _ux_NavigatorTabControl.TabPages.Clear();
            }

            // Now that selecting the CNO above has triggered the creation of the Navigator TabControl, place it in the left pane...
            ux_panelNavigator.Controls.Clear();
            ux_panelNavigator.Controls.Add(_ux_NavigatorTabControl);
            _ux_NavigatorTabControl.Size = ux_panelNavigator.Size;
            _ux_NavigatorTabControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;

            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
开发者ID:egacheru,项目名称:G2,代码行数:80,代码来源:NavigatorTabControl.cs

示例9: getXML

        private void getXML(TabControl t)
        {
            if (File.Exists(Application.StartupPath + "\\TabPage.xml"))
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Application.StartupPath + "\\TabPage.xml");
                XmlNode node = xmlDoc.SelectSingleNode("TabPage");
                XmlNode node1 = node.SelectSingleNode(treeName);
                XmlNode node2 = node1.ChildNodes[0];
                if (node2 != null)
                {
                    if (node2.Name == "分站状态")
                    {
                        t.SelectTab(0);
                    }
                    else if (node2.Name == "实时下井人员")
                    {
                        t.SelectTab(1);

                    }
                    else if (node2.Name == "实时区域")
                    {
                        t.SelectTab(2);
                    }
                    else if (node2.Name == "检卡信息表")
                    {
                        t.SelectTab(0);
                    }
                    else
                    {
                        t.SelectTab(1);
                    }
                    #region[读字体]
                    XmlDocument xmlDoc2 = new XmlDocument();
                    xmlDoc2.Load(Application.StartupPath + "\\tree.xml");
                    XmlNode nodeTree = xmlDoc2.SelectSingleNode("tree");
                    XmlNode nodePage = nodeTree.SelectSingleNode(treeName);
                    foreach (XmlNode cruNode in nodePage)
                    {

                        if (cruNode.HasChildNodes && cruNode.ChildNodes[0].Name.Contains("表"))
                        {

                            string sql = cruNode.ChildNodes[0].SelectSingleNode("sql").InnerText;
                            string ziti = cruNode.ChildNodes[0].SelectSingleNode("字体").InnerText;
                            ziti = ziti.Replace("[FontFamily: Name=", "").Replace("]", "");
                            float zihao = (float)(Convert.ToDouble(cruNode.ChildNodes[0].SelectSingleNode("字号").InnerText));
                            string yangshi = cruNode.ChildNodes[0].SelectSingleNode("样式").InnerText;
                            string yanse = cruNode.ChildNodes[0].SelectSingleNode("颜色").InnerText;
                            yanse = yanse.Substring(yanse.IndexOf("[") + 1, yanse.IndexOf("]") - yanse.IndexOf("[") - 1);
                            dataGridView1.RowsDefaultCellStyle.ForeColor = Color.FromName(yanse);
                            dataGridView1.RowsDefaultCellStyle.Font = new Font(ziti, zihao, (System.Drawing.FontStyle)Enum.Parse(typeof(System.Drawing.FontStyle), yangshi, false));
                            dataGridView1.RowsDefaultCellStyle.SelectionForeColor = dataGridView1.RowsDefaultCellStyle.ForeColor;
                            dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.FromName(yanse);
                            dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font(ziti, zihao, (System.Drawing.FontStyle)Enum.Parse(typeof(System.Drawing.FontStyle), yangshi, false));
                        }
                    }
                    #endregion
                    NodeSelect = node2.Name;
                    checkBox = node2.InnerText.Substring(0, node2.InnerText.Length - 1).Split(',');
                }
            }
            else
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlElement ele1 = xmlDoc.CreateElement("TabPage");
                xmlDoc.AppendChild(ele1);
                XmlElement ele2 = xmlDoc.CreateElement("文本信息");
                XmlElement ele3 = xmlDoc.CreateElement("监控信息");
                XmlElement ele4 = xmlDoc.CreateElement("常规信息");
                ele1.AppendChild(ele2);
                ele1.AppendChild(ele3);
                ele1.AppendChild(ele4);
                xmlDoc.Save(Application.StartupPath + "\\TabPage.xml");
            }

            XmlDocument xmlDoc1 = new XmlDocument();
            xmlDoc1.Load(Application.StartupPath + "\\LedConfig.xml");

            tableTime = Convert.ToInt32(xmlDoc1.SelectSingleNode("Config/TableFlesh").InnerText);

            #region【Led大屏显示特定分站信息-2013-12-05】
            XmlDocument xmlCzlt = new XmlDocument();
            xmlCzlt.Load(Application.StartupPath + "\\ShowConfig.xml");
            LedStaID = xmlCzlt.SelectSingleNode("Config/LedStaID").InnerText.Trim();
            if (LedStaID.Trim().Equals(""))
            {
                LedStaID = " and 1=1 ";
            }
            else
            {
                LedStaID = " and stationAddress in ("+LedStaID+") ";
            }


            MineStaID = xmlCzlt.SelectSingleNode("Config/MineStaID").InnerText.Trim();
            if (MineStaID.Trim().Equals(""))
            {
                MineStaID = " and 1=1 ";
            }
//.........这里部分代码省略.........
开发者ID:dreamsxin,项目名称:LEDShow2.0,代码行数:101,代码来源:TableFrm.cs

示例10: AddUserControl

        /// <summary>
        /// Allows to add new task control
        /// </summary>
        /// <param name="id">task ID</param>
        /// <param name="tabControl">TabControl to add to</param>
        private void AddUserControl(TabControl tabControl, long id = -1)
        {
            try
            {
                tabControl.SelectTab(
                    tabControl.TabPages
                        .Cast<TabPage>()
                        .First(x => x.Tag != null
                                    && x.Tag.ToString() == id.ToString(CultureInfo.InvariantCulture)));
            }
            catch (Exception)
            {
                var tp = new TabPage {Tag = id};
                var tuc = new TaskUserControl(this, id) {Dock = DockStyle.Fill};
                tuc.TaskOpened += AddUserControl;
                tuc.TaskClosed += TucTaskClosed;
                tp.Controls.Add(tuc);

                tabControl.TabPages.Add(tp);
                tabControl.SelectTab(tp);
            }
        }
开发者ID:vermilion,项目名称:TaskManager,代码行数:27,代码来源:MainForm.cs

示例11: EventSelected

		public void EventSelected ()
		{
			Form f = new Form ();
			TabControl tc = new TabControl ();
			TabControlEventArgs tcea1 = new TabControlEventArgs (null, 0, TabControlAction.Deselected);
			TabControlEventArgs tcea2 = new TabControlEventArgs (null, 0, TabControlAction.Selected);
			TabControlCancelEventArgs tccea1 = new TabControlCancelEventArgs (null, 0, false, TabControlAction.Deselecting);
			TabControlCancelEventArgs tccea2 = new TabControlCancelEventArgs (null, 0, false, TabControlAction.Selecting);
			
			f.Controls.Add (tc);
			string events = string.Empty;
			tc.SelectedIndexChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("SelectedIndexChanged;"); });
			tc.Deselecting += new TabControlCancelEventHandler (delegate (Object obj, TabControlCancelEventArgs e) { events += ("Deselecting;"); tccea1 = e; });
			tc.Deselected += new TabControlEventHandler (delegate (Object obj, TabControlEventArgs e) { events += ("Deselected;"); tcea1 = e; });
			tc.Selecting += new TabControlCancelEventHandler (delegate (Object obj, TabControlCancelEventArgs e) { events += ("Selecting;"); tccea2 = e; });
			tc.Selected += new TabControlEventHandler (delegate (Object obj, TabControlEventArgs e) { events += ("Selected;"); tcea2 = e; });
			
			TabPage tp1 = new TabPage ("One");
			TabPage tp2 = new TabPage ("Two");
			
			tc.TabPages.Add (tp1);
			tc.TabPages.Add (tp2);
			
			f.Show ();
			tc.SelectTab (1);
			Assert.AreEqual ("Deselecting;Deselected;Selecting;Selected;SelectedIndexChanged;", events, "A1");
			Assert.AreEqual (TabControlAction.Deselecting, tccea1.Action, "A2");
			Assert.AreEqual (TabControlAction.Deselected, tcea1.Action, "A2");
			Assert.AreEqual (TabControlAction.Selecting, tccea2.Action, "A2");
			Assert.AreEqual (TabControlAction.Selected, tcea2.Action, "A2");
			Assert.AreSame (tp2, tcea2.TabPage, "A3");
			Assert.AreEqual (1, tcea2.TabPageIndex, "A4");
			f.Close ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:34,代码来源:TabControlTest.cs

示例12: MethodSelectTabAOORE2

		public void MethodSelectTabAOORE2 ()
		{
			TabControl tc = new TabControl ();
			tc.TabPages.Add (new TabPage ("One"));
			tc.TabPages.Add (new TabPage ("Two"));

			tc.SelectTab (2);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:TabControlTest.cs

示例13: MethodSelectTab

		public void MethodSelectTab ()
		{
			TabControl tc = new TabControl ();
			tc.TabPages.Add ("One", "One");
			tc.TabPages.Add ("Two", "Two");
			tc.TabPages.Add ("Three", "Three");
			
			tc.SelectTab (1);
			Assert.AreEqual (1, tc.SelectedIndex, "A1");

			tc.SelectTab (tc.TabPages[2]);
			Assert.AreEqual (2, tc.SelectedIndex, "A2");

			tc.SelectTab ("One");
			Assert.AreEqual (0, tc.SelectedIndex, "A3");

			tc.SelectTab (1);
			tc.DeselectTab (1);
			Assert.AreEqual (2, tc.SelectedIndex, "A4");

			tc.DeselectTab (2);
			Assert.AreEqual (0, tc.SelectedIndex, "A5");

			tc.DeselectTab (tc.TabPages[0]);
			Assert.AreEqual (1, tc.SelectedIndex, "A6");		

			tc.DeselectTab (tc.TabPages[0]);
			Assert.AreEqual (1, tc.SelectedIndex, "A7");		

			tc.DeselectTab (tc.TabPages[1]);
			Assert.AreEqual (2, tc.SelectedIndex, "A7");		

			tc.DeselectTab ("Two");
			Assert.AreEqual (2, tc.SelectedIndex, "A8");		

			tc.DeselectTab ("Three");
			Assert.AreEqual (0, tc.SelectedIndex, "A8");		
		}
开发者ID:Profit0004,项目名称:mono,代码行数:38,代码来源:TabControlTest.cs


注:本文中的System.Windows.Forms.TabControl.SelectTab方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。