//绑定菜单
private void BindMenu(DataTable dt)
{
foreach (DataRow row in dt.Rows)
{
ToolStripItem item
= new ToolStripMenuItem();
item.Name
= row[0].ToString();
item.Text
= row[1].ToString();
item.Click
+= new EventHandler(contextMenuStrip1_ItemClick);
contextMenuStrip1.Items.Add(item);
//contextMenuStrip1.Items.Add(row[1].ToString(), null, contextMenuStrip1_ItemClick);
}
}

private void contextMenuStrip1_ItemClick(object sender, EventArgs e)
{
ToolStripItem item
= (ToolStripItem)sender;
MessageBox.Show(item.Name);
}

相关文章:

  • 2021-04-20
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-09-22
猜你喜欢
  • 2022-01-24
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-10-25
  • 2022-02-07
相关资源
相似解决方案