开源控件OutlookBar左边菜单怎样获得点击事件?
public partial class Form1 : Form{
private OutlookBar outlookBar1 = null;
public Form1()
{
InitializeComponent();
InitializeOutlookbar();
}
private void InitializeOutlookbar()
{
outlookBar1 = new OutlookBar();
OutlookBarBand oneBand = new OutlookBarBand("水果");
oneBand.SmallImageList = this.imageList1;
oneBand.LargeImageList = this.imageList1;
oneBand.Items.Add(new OutlookBarItem("苹果", 0));
oneBand.Items.Add(new OutlookBarItem("梨子", 1));
oneBand.Items.Add(new OutlookBarItem("香蕉", 2));
oneBand.Items.Add(new OutlookBarItem("橘子", 3));
oneBand.Background = SystemColors.AppWorkspace;
oneBand.TextColor = Color.White;
outlookBar1.Bands.Add(oneBand);
OutlookBarBand twoBand = new OutlookBarBand("蔬菜");
twoBand.SmallImageList = this.imageList1;
twoBand.LargeImageList = this.imageList1;
twoBand.Items.Add(new OutlookBarItem("白菜", 0));
twoBand.Items.Add(new OutlookBarItem("豆腐", 1));
twoBand.Items.Add(new OutlookBarItem("茄子", 2));
twoBand.Items.Add(new OutlookBarItem("子姜", 3));
twoBand.Background = SystemColors.AppWorkspace;
twoBand.TextColor = Color.White;
outlookBar1.Bands.Add(twoBand);
OutlookBarBand threeBand = new OutlookBarBand("糕点");
threeBand.SmallImageList = this.imageList1;
threeBand.LargeImageList = this.imageList1;
threeBand.Items.Add(new OutlookBarItem("凤尾酥", 0));
threeBand.Items.Add(new OutlookBarItem("南瓜饼", 1));
threeBand.Items.Add(new OutlookBarItem("桂花糕", 2));
threeBand.Items.Add(new OutlookBarItem("双河凉糕", 3));
threeBand.Background = SystemColors.AppWorkspace;
threeBand.TextColor = Color.White;
outlookBar1.Bands.Add(threeBand);
OutlookBarBand fourBand = new OutlookBarBand("电影");
fourBand.SmallImageList = this.imageList1;
fourBand.LargeImageList = this.imageList1;
fourBand.Items.Add(new OutlookBarItem("敢死队", 0));
fourBand.Items.Add(new OutlookBarItem("功夫", 1));
fourBand.Items.Add(new OutlookBarItem("英雄", 2));
fourBand.Items.Add(new OutlookBarItem("V字仇杀队", 3));
fourBand.Background = SystemColors.AppWorkspace;
fourBand.TextColor = Color.White;
outlookBar1.Bands.Add(fourBand);
outlookBar1.Dock = DockStyle.Fill;
this.panel1.Controls.AddRange(new Control[] { outlookBar1 });
outlookBar1.FlatArrowButtons = true;
//outlookBar1.FlatArrowButtons = true;在窗体属性中操作,这里是自定义的空间,需要写代码
//outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped);
outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked);
}
/// <summary>
/// 点击事件
/// </summary>
/// <param name="band"></param>
/// <param name="item"></param>
private void OnOutlookBarItemClicked(OutlookBarBand band,OutlookBarItem item)
{
switch (item.Text)
{
case "苹果":
MessageBox.Show("苹果");
break;
case "梨子":
Form2 form2 = new Form2();
form2.Show(this.dockPanel1);
form2.DockTo(this.dockPanel1, DockStyle.Right);
break;
case "香蕉":
Form3 form3 = new Form3();
form3.Show(this.dockPanel1);
form3.DockTo(this.dockPanel1, DockStyle.Right);
break;
default:
break;
}
}
在运行此代码,需要引入一个开源控件的Dll
怎样获得点击菜单"水果"、糕点"、电影"事件
OutlookBarBand oneBand = new OutlookBarBand("水果");
OutlookBarBand threeBand = new OutlookBarBand("糕点");
OutlookBarBand fourBand = new OutlookBarBand("电影");
现在已经能获得点击菜单"水果"的子菜单"苹果"、"梨子"、"香蕉"、"橘子".
我的剩余分数不多了,请大哥大姐们帮下忙,帮我解决一下,我都弄了好久了,都没弄出来!!!
谢谢了 --------------------编程问答-------------------- I want to know --------------------编程问答-------------------- 麻烦高手解决一下我的这个问题!!
非常感谢!!!
补充:.NET技术 , C#