关闭tab时,定位到导航栏对应的激活tab

        /// <summary>
        /// 关闭tab时,定位到导航栏对应的激活tab
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DXtrtable_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {               
            if (e.Page.Tag == null)
            {
                return;
            }
            string functionCode = e.Page.Tag.ToString(); //Tab,每个Tab的代码
            this.SelectItem(functionCode);
        }
/// <summary>
        /// DevExpress.XtraNavBar.NavBarControl 导航控件定位或选中状态
        /// 另导航的选项为选中状态
        /// </summary>
        /// <param name="functionCode">Tag的代码,需要定位的导航项</param>
        private void SelectItem(string functionCode)
        {
            Console.WriteLine(String.Concat("SelectItem", functionCode));
            var length = this.DnBarControl.Groups.Count;
            for (int groupIndex = 0; groupIndex < length; groupIndex++)
            {
                var itemLength = this.DnBarControl.Groups[groupIndex].ItemLinks.Count;

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

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

                        return;

                    }
                }
            }
        }

 

posted @ 2017-05-17 20:16  一路来过  阅读(408)  评论(0编辑  收藏  举报