//
绑定菜单
private
void
BindMenu(DataTable dt) {
foreach
(DataRow row
in
dt.Rows) { ToolStripItem item
=
new
ToolStripMenuItem(); item.Name
row[
0
].ToString(); item.Text
1
].ToString(); item.Click
+=
EventHandler(contextMenuStrip1_ItemClick); contextMenuStrip1.Items.Add(item);
contextMenuStrip1.Items.Add(row[1].ToString(),null,contextMenuStrip1_ItemClick);
} }
contextMenuStrip1_ItemClick(
object
sender,EventArgs e) { ToolStripItem item
(ToolStripItem)sender; MessageBox.Show(item.Name); }
|
原文链接:https://www.f2er.com/vb/261642.html