日期:2014-05-17 浏览次数:21211 次
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//可以从数据库或者其他数据源获取数据绑定
for (int i = 0; i < 5; i++)
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Tag = i;
item.Text = "测试" + i;
item.Click += HandlerItemClick;
toolStripDropDownButton.DropDownItems.Add(item);
}
}
private void HandlerItemClick(object sender, EventArgs e)
{
MessageBox.Show((sender as ToolStripMenuItem).Tag.ToString());
}
}