我有一个由项目和客户两项组成的菜单条。根据用户的ID,每个项目都会有不同的子项目。但是,我面临的问题是如何将每个子项与特定的表单连接起来。在整个搜索过程中,我执行了以下操作:
Dim userid = Textbox1.text
if userid = "1001" then
Dim p1 As New ToolStripMenuItem
p1 = Form1.ProjectToolStripMenuItem
p1.DropDownItems.Add("Add Project")
AddHandler p1.DropDownItemClicked, AddressOf add_project_click
Dim p2 As ToolStripMenuItem
p2 = Form1.ProjectToolStripMenuItem
p2.DropDownItems.Add("Modify Project")
else
Dim p2 As ToolStripMenuItem
p2 = Form1.ProjectToolStripMenuItem
p2.DropDownItems.Add("Modify Project")
end if
Private Sub add_project_click(ByVal sender As Object, ByVal e As EventArgs)
AddProjectForm.Show()
End Sub
现在的问题是,AddHandler p1.DropDownItemClicked, AddressOf add_project_click
当我单击项目项并单击添加项目或修改项目时,两者都将显示添加项目的形式。