码迷,mamicode.com
首页 > 编程语言 > 详细

选中Tab控件单击事件,点击tab头,定位到导航栏的选项,为选中状态 ,DevExpress.XtraNavBar.NavBarControl 导航控件定位或选中状态 另导航的选项为选中状态.

时间:2017-05-14 13:43:26      阅读:1321      评论:0      收藏:0      [点我收藏+]

标签:logs   link   状态   dev   navbar   break   选中   line   length   

         /// <summary>
        /// 选中Tab控件单击事件,点击tab头,定位到导航栏的选项,为选中状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void xtraTabControl1_Click(object sender, EventArgs e)
        {
            XtraTabControl obj = sender as XtraTabControl;
            DevExpress.XtraTab.XtraTabPage page = obj.SelectedTabPage;
            string switch_on = page.Tag.ToString(); //Tab,每个Tab的代码
            switch (switch_on)
            {
                case "2001":                    
                    SelectItem(switch_on);
                    break;
                case "2002":
                    SelectItem(switch_on);

                    break;

                case "2003":
                    SelectItem(switch_on);
                    break;

                case "2004":
                    SelectItem(switch_on);
                    break;

                case "2005":
                    SelectItem(switch_on);
                    break;

                case "2006":
                    SelectItem(switch_on);
                    break;

                case "2007":
                    SelectItem(switch_on);
                    break;
                
                default:
                    break;
            }

        }

        /// <summary>
        /// DevExpress.XtraNavBar.NavBarControl 导航控件定位或选中状态
        /// 另导航的选项为选中状态
        /// </summary>
        /// <param name="functionCode">Tag的代码,需要定位的导航项</param>
        private void SelectItem(string functionCode)
        {
            Console.WriteLine(functionCode);
            var length = this.navBarControl1.Groups.Count;
            for (int groupIndex = 0; groupIndex < length; groupIndex++)
            {
                var itemLength = this.navBarControl1.Groups[groupIndex].ItemLinks.Count;             

                for (int itemIndex = 0; itemIndex < itemLength; itemIndex++)
                {
                    var result = this.navBarControl1.Groups[groupIndex].ItemLinks[itemIndex].Item.Tag.ToString(); 

                    if (result == functionCode)
                    {
                        this.navBarControl1.Groups[groupIndex].Expanded = true;
                        navBarControl1.Groups[groupIndex].SelectedLinkIndex = itemIndex;                      

                        return;
                       
                    }                 

                }

            }
        }

 

选中Tab控件单击事件,点击tab头,定位到导航栏的选项,为选中状态 ,DevExpress.XtraNavBar.NavBarControl 导航控件定位或选中状态 另导航的选项为选中状态.

标签:logs   link   状态   dev   navbar   break   选中   line   length   

原文地址:http://www.cnblogs.com/panxihua/p/6852109.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!