当用户按下按钮时,我想使用这个小上下文菜单:
private ContextMenuStrip TaskMenu()
{
ContextMenuStrip Result = new ContextMenuStrip();
Result.Items.Add("Select task to start:");
Result.Items.AddRange(
System.IO.Directory.GetFiles("C:\\Settings\\Tasks", true), "*.tsk")
.Select(qF => new ToolStripMenuItem(System.IO.Path.GetFileNameWithoutExtension(qF)) { Tag = qF, Checked = qF == this.TaskFile })
.ToArray());
Result.Items.Add("Cancel");
Result.ItemClicked += new ToolStripItemClickedEventHandler(
delegate(object s, ToolStripItemClickedEventArgs ev) { StartScan((string)ev.ClickedItem.Tag); });
return Result;
}
但是,我不应该这样做,因为我从不取消订阅该活动。正确的?