c# 实现右键点击navbarcontrol 里的 navbaritem 怎么实现右键菜单 20
c#实现右键点击navbarcontrol里的navbaritem怎么实现右键菜单这个控件中没有右键的事件不知道如何去实现右键菜单...
c# 实现右键点击navbarcontrol 里的 navbaritem 怎么实现右键菜单
这个控件中 没有右键的 事件 不知道 如何去 实现右键菜单 展开
这个控件中 没有右键的 事件 不知道 如何去 实现右键菜单 展开
展开全部
您好,您这样:
private void button1_Click_1(object sender, EventArgs e)
{
CreateMainMenu();
}
void CreateMainMenu()
{
List<MainMenu> mainList = new List<MainMenu>();
for (int i = 1; i < 5; i++)
{
MainMenu m = new MainMenu();
m.MID = i;
m.Title = "A" + i;
mainList.Add(m);
}
DevExpress.XtraNavBar.NavBarGroup[] groups = new DevExpress.XtraNavBar.NavBarGroup[mainList.Count];
for (int i = 0; i < mainList.Count; i++)
{
DevExpress.XtraNavBar.NavBarGroup group = new DevExpress.XtraNavBar.NavBarGroup();
group.Caption = mainList[i].Title.ToString();
groups[i] = group;
CreateSubMenu(mainList[i].MID.ToString(), group);
}
nbleft.Groups.AddRange(groups);
}
void CreateSubMenu(string groupid, DevExpress.XtraNavBar.NavBarGroup group)
{
for (int i = 0; i < 3; i++)
{
DevExpress.XtraNavBar.NavBarItem item = new DevExpress.XtraNavBar.NavBarItem();
item.Caption = "a" + i;
item.LinkClicked += new DevExpress.XtraNavBar.NavBarLinkEventHandler(item_LinkClicked);
group.ItemLinks.Add(item);
}
}
void item_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
{
throw new NotImplementedException();
}
public class MainMenu
{
public int MID { get; set; }
public string Title{get;set;}
}
public class SubMenu
{
public int SID { get; set; }
public string STitl { get; set; }
}
private void button1_Click_1(object sender, EventArgs e)
{
CreateMainMenu();
}
void CreateMainMenu()
{
List<MainMenu> mainList = new List<MainMenu>();
for (int i = 1; i < 5; i++)
{
MainMenu m = new MainMenu();
m.MID = i;
m.Title = "A" + i;
mainList.Add(m);
}
DevExpress.XtraNavBar.NavBarGroup[] groups = new DevExpress.XtraNavBar.NavBarGroup[mainList.Count];
for (int i = 0; i < mainList.Count; i++)
{
DevExpress.XtraNavBar.NavBarGroup group = new DevExpress.XtraNavBar.NavBarGroup();
group.Caption = mainList[i].Title.ToString();
groups[i] = group;
CreateSubMenu(mainList[i].MID.ToString(), group);
}
nbleft.Groups.AddRange(groups);
}
void CreateSubMenu(string groupid, DevExpress.XtraNavBar.NavBarGroup group)
{
for (int i = 0; i < 3; i++)
{
DevExpress.XtraNavBar.NavBarItem item = new DevExpress.XtraNavBar.NavBarItem();
item.Caption = "a" + i;
item.LinkClicked += new DevExpress.XtraNavBar.NavBarLinkEventHandler(item_LinkClicked);
group.ItemLinks.Add(item);
}
}
void item_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
{
throw new NotImplementedException();
}
public class MainMenu
{
public int MID { get; set; }
public string Title{get;set;}
}
public class SubMenu
{
public int SID { get; set; }
public string STitl { get; set; }
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询