當前位置: 首頁>>代碼示例>>C#>>正文


C# UserControl.Focus方法代碼示例

本文整理匯總了C#中System.Windows.Forms.UserControl.Focus方法的典型用法代碼示例。如果您正苦於以下問題:C# UserControl.Focus方法的具體用法?C# UserControl.Focus怎麽用?C# UserControl.Focus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.UserControl的用法示例。


在下文中一共展示了UserControl.Focus方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LoadUC

 public void LoadUC(UserControl ucContent)
 {
     pnMain.Controls.Clear();
     ucContent.Dock = DockStyle.Fill;
     pnMain.Controls.Add(ucContent);
     ucContent.Focus();
 }
開發者ID:hynguyen2610,項目名稱:OlympicGym,代碼行數:7,代碼來源:MainForm.cs

示例2: Swap_View

 private void Swap_View(UserControl uc1, UserControl uc2)
 {
     edit = !edit;
     this.Controls.Remove(uc1);
     this.Controls.Add(uc2);
     uc2.Focus();
 }
開發者ID:jollywho,項目名稱:eiKanji,代碼行數:7,代碼來源:Form1.cs

示例3: addUserControls

        /// <summary>
        /// 添加標簽 添加內容窗體
        /// </summary>
        /// <param name="userContol">新窗體</param>
        /// <param name="memuName">標簽名</param>
        /// <param name="menuId">三級菜單id</param>
        /// <param name="thisUcTag">當前窗體Tag tag包括(三級|一級| 二級 菜單的id)</param>
        /// ///  <param name="PUCName">父窗體Name</param>
        public void addUserControls(UserControl userContol, string memuName, string menuId, string thisUcTag, string PUCName)
        {
            try
            {
                if (thisUcTag != null)
                {
                    string[] strArr = thisUcTag.Split('|');
                    if (!panel_Content.Controls.ContainsKey(menuId))
                    {
                        Image myImage = null;
                        if (GlobalStaticObj.gLoginDataSet != null
                            && GlobalStaticObj.gLoginDataSet.Tables.Count > 2
                            && GlobalStaticObj.gLoginDataSet.Tables[2] != null
                            && GlobalStaticObj.gLoginDataSet.Tables[2].Rows.Count > 0)
                        {
                            DataView dv = GlobalStaticObj.gLoginDataSet.Tables[2].DefaultView;
                            dv.RowFilter = "fun_id='" + strArr[0] + "'";
                            if (dv.Count > 0)
                            {
                                DataRowView drv = dv[0];
                                if (drv["fun_img"] != DBNull.Value && drv["fun_img"].ToString().Length > 0)
                                {
                                    myImage = ServiceStationClient.Skin.SkinAssistant.GetResourcesImage(drv["fun_img"]);
                                }
                            }
                        }

                        userContol.Name = menuId;
                        userContol.Dock = DockStyle.Fill;
                        userContol.Focus();
                        panel_Content.Controls.Add(userContol);// panel_Main.Controls.Add(ucHome);                   
                        userContol.BringToFront();
                        userContol.Tag = menuId + "|" + strArr[1] + "|" + strArr[2] + "|" + PUCName;

                        childmemu(myImage, memuName, menuId, strArr[2], strArr[1], PUCName);
                    }
                    else
                    {
                        this.panel_Content.Controls.Find(menuId, false)[0].BringToFront();
                        childMemuState(menuId);
                    }
                    SYSModel.clsSysConfig.STR_CURR_TWOMEMU = strArr[2];
                }
                else
                {
                    userContol.Dock = DockStyle.Fill;
                    userContol.Focus();
                    panel_Content.Controls.Add(userContol);// panel_Main.Controls.Add(ucHome);                   
                    userContol.BringToFront();
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(ex.Message);
            }
            
        }
開發者ID:caocf,項目名稱:workspace-kepler,代碼行數:65,代碼來源:HXCMainForm.cs

示例4: addUserControls

        /// <summary>
        /// 添加標簽 添加內容窗體
        /// </summary>
        /// <param name="userContol">新窗體</param>
        /// <param name="memuName">標簽名</param>
        /// <param name="menuId">三級菜單id</param>
        /// <param name="thisUcTag">當前窗體Tag tag包括(三級|一級| 二級 菜單的id)</param>
        /// ///  <param name="PUCName">父窗體Name</param>
        public void addUserControls(UserControl userContol, string memuName, string menuId, string thisUcTag, string PUCName)
        {
            try
            {
                if (thisUcTag != null)
                {
                    string[] strArr = thisUcTag.Split('|');
                    if (!panel_Content.Controls.ContainsKey(menuId))
                    {
                        if (this.menus.Count >= MaxPage)
                        {
                            MessageBoxEx.ShowWarning("頁簽打開數量已達到最大上限,請先關閉頁簽!");
                            return;
                        }

                        List<string> visibleMenu = new List<string>();
                        foreach (Control ctl in panel_Content.Controls)
                        {
                            if (ctl is UserControl)
                            {
                                if (ctl.Name != menuId && ctl.Visible)
                                {
                                    visibleMenu.Add(ctl.Name);
                                }
                            }
                        }

                        Image myImage = null;
                        DataRow dr = LocalCache.GetFunction(strArr[0]);
                        if (dr != null)
                        {
                            if (dr["fun_img"].ToString().Length > 0)
                            {
                                myImage = SkinAssistant.GetResourcesImage(dr["fun_img"]);
                            }
                        }

                        userContol.Name = menuId;
                        userContol.Dock = DockStyle.Fill;
                        userContol.Focus();
                        panel_Content.Controls.Add(userContol);// panel_Main.Controls.Add(ucHome);                   
                        userContol.BringToFront();
                        userContol.Tag = menuId + "|" + strArr[1] + "|" + strArr[2] + "|" + PUCName;

                        //添加菜單
                        menus.Add(menuId, userContol.Tag.ToString());
                        this.currentMenu = menuId;

                        foreach (string menu in visibleMenu)
                        {
                            this.panel_Content.Controls[menu].Visible = false;
                        }

                        childmemu(myImage, memuName, menuId, strArr[2], strArr[1], PUCName);
                    }
                    else
                    {
                        this.currentMenu = menuId;

                        this.panel_Content.Controls.Find(menuId, false)[0].Visible = true;
                        this.panel_Content.Controls.Find(menuId, false)[0].BringToFront();
                        foreach (Control ctl in panel_Content.Controls)
                        {
                            if (ctl.Name != menuId && ctl.Visible && (ctl is UserControl))
                            {
                                ctl.Visible = false;
                            }
                        }
                        childMemuState(menuId);
                    }
                    SYSModel.clsSysConfig.STR_CURR_TWOMEMU = strArr[2];
                }
                else
                {
                    if (this.menus.Count >= MaxPage)
                    {
                        MessageBoxEx.ShowWarning("頁簽打開數量已達到最大上限,請先關閉頁簽!");
                        return;
                    }

                    userContol.Dock = DockStyle.Fill;
                    userContol.Focus();
                    panel_Content.Controls.Add(userContol);
                    userContol.BringToFront();

                    //添加菜單
                    menus.Add(menuId, memuName);
                    this.currentMenu = menuId;

                    foreach (Control ctl in panel_Content.Controls)
                    {
                        if (ctl.Name != menuId && ctl.Visible && (ctl is UserControl))
//.........這裏部分代碼省略.........
開發者ID:caocf,項目名稱:workspace-kepler,代碼行數:101,代碼來源:HXCMainForm.cs

示例5: addUserControls

 /// <summary> 添加標簽 添加內容窗體
 /// </summary>
 /// <param name="userContol">新窗體</param>
 /// <param name="memuName">標簽名</param>
 /// <param name="menuId">三級菜單id</param>
 /// <param name="thisUcTag">當前窗體Tag tag包括(三級 |一級| 二級 菜單的id)</param>
 public void addUserControls(UserControl userContol, string memuName, string menuId, string thisUcTag, string PUCName)
 {
     try
     {
         if (thisUcTag != null)
         {
             string[] strArr = thisUcTag.Split('|');
             if (panel_Content.Controls.Find(menuId, true).Length == 0)
             {
                 userContol.Name = menuId;
                 userContol.Dock = DockStyle.Fill;
                 userContol.Focus();
                 userContol.Tag = menuId + "|" + strArr[1] + "|" + strArr[2];
                 panel_Content.Controls.Add(userContol);// panel_Main.Controls.Add(ucHome);
                 userContol.BringToFront();
                 Image myImage = null;
                 if (GlobalStaticObj.gLoginDataSet != null && GlobalStaticObj.gLoginDataSet.Tables[2] != null && GlobalStaticObj.gLoginDataSet.Tables[2].Rows.Count > 0)
                 {
                     DataView dv = GlobalStaticObj.gLoginDataSet.Tables[2].DefaultView;
                     dv.RowFilter = "fun_id='" + strArr[0] + "'";
                     if (dv.Count > 0)
                     {
                         DataRowView drv = dv[0];
                         if (drv["fun_img"] != DBNull.Value && drv["fun_img"].ToString().Trim() != "")
                         {
                             myImage = (Image)ServiceStationClient.Skin.Properties.Resources.ResourceManager.GetObject(drv["fun_img"].ToString());
                         }
                     }
                 }
                 childmemu(myImage, memuName, menuId, strArr[2], strArr[1], PUCName);
             }
             else
             {
                 panel_Content.Controls.Find(menuId, true)[0].BringToFront();
                 childMemuState(menuId);
             }
             SYSModel.clsSysConfig.STR_CURR_TWOMEMU = strArr[2];
         }
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("MainForm", ex);
         MessageBoxEx.ShowWarning("程序異常");
     }
 }
開發者ID:caocf,項目名稱:workspace-kepler,代碼行數:51,代碼來源:HXCServerMainForm.cs

示例6: ShowControl

 private void ShowControl(UserControl control)
 {
     control.Focus();
     control.BringToFront();
     control.Dock = DockStyle.Fill;
 }
開發者ID:garciagars,項目名稱:ComDriveSW,代碼行數:6,代碼來源:frmArea.cs

示例7: UserControlFocus

		public void UserControlFocus ()
		{
			Form form = new Form ();
			UserControl c = new UserControl ();
			TextBox t1 = new TextBox ();
			TextBox t2 = new TextBox ();
			form.Controls.Add (t1);
			c.Controls.Add (t2);
			form.Controls.Add (c);
			form.Show ();
			
			c.Focus ();
			
			Assert.IsTrue (t2.Focused, "#A1");
			Assert.AreSame (t2, c.ActiveControl, "#A2");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:16,代碼來源:FocusTest.cs

示例8: AddModule

 private void AddModule(UserControl userControl)
 {
     userControl.Location = new System.Drawing.Point(0, 0);
     userControl.Size = new System.Drawing.Size(238, 320);
     this.plMain.Controls.RemoveAt(0);
     this.plMain.Controls.Add(userControl);
     this.Activate();
     userControl.Focus();
 }
開發者ID:zhsh1241,項目名稱:Sconit5_Shenya,代碼行數:9,代碼來源:MainForm.cs


注:本文中的System.Windows.Forms.UserControl.Focus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。