整理c# 不常用但有用代码
private void contextMenuStripHandler_Click(object sender, EventArgs e)
{
ContextMenuStrip menu = sender as ContextMenuStrip;
foreach (ToolStripMenuItem item in menu.Items)
{
if (item.Selected)
{
int index = dgInfo.CurrentCell.RowIndex;
Object[] parameters = new Object[2]; // 定义构造函数需要的参数,所有参数都必须为Object
parameters[0] = dgInfo.Rows[index].Cells["orderNo"].Value;
parameters[1] = dgInfo.Rows[index].Cells["remark"].Value;
Assembly assembly = Assembly.GetExecutingAssembly(); // 获取当前程序集
var newForm = (Form)assembly.CreateInstance("QZJP.Agent.Platform.AutoTicket." + item.ToolTipText, true, System.Reflection.BindingFlags.Default,
null, parameters, null, null);
newForm.StartPosition = FormStartPosition.CenterScreen;
newForm.Show();
}
}
}