我想在 vb.net 中创建一个自定义控件,其行为类似于 vb6 popupmenu 并且其行为类似于 form show dialog 。弹出菜单动态填充,我的 O/P 仅取决于弹出菜单的点击事件结果。
通过使用 context menustrip 问题是 context menustrip 的 click 事件在调用 context menustrip 的所有表单事件之后引发。因此,我无法使用上下文菜单项单击结果在 Mainform 中继续程序的其余部分。
我的主窗体 MouseUp 被调用
显示 MouseUp 上下文菜单内部
Show of Context Menu Strip 之后 Main Form MouseUp Continues 的下一行从获得的结果
ContextMenuStrip_ItemClicked
ContextMenuStrip_ItemClicked
有很多其他功能和代码无法在它之外替换
代码:
Private Sub ChangeLayer(ByRef X As Double, ByRef Y As Double, ByRef D As String, ByRef T As Integer)''*****Change Layer Called in MouseUp Event of MainForm
Dim A As String
Dim objDrawingPoint As New Drawing.Point
Dim cms As New ContextMenuStrip
DeleteFlag = False
'A = M_PlaceLayer.Text
A = PlaceOn.Text
If T Then
M_SelLayC(0).Enabled = False : M_SelLayC(1).Enabled = False
M_SelLayS(16).Enabled = False : M_SelLayS(17).Enabled = False
CompLayer(0).Enabled = False : CompLayer(1).Enabled = False
SolderLayer(16).Enabled = False : SolderLayer(17).Enabled = False
End If
'' M_PlaceLayer.Text = StrAnsi(D)
PlaceOn.Text = StrAnsi(D)
m_LayerFlag = False
objDrawingPoint = ViewPicture.PointToClient(Cursor.Position)
With objDrawingPoint
cm_FO.Show(ViewPicture, New Point(.X, .Y))'''**Context MenuStrip Show()
End With
'''''Depends on Result of ItemClicked of cm_FO contextmenustrip below code works
'******************************************************
'Code Below Works with result of Context MenuStrip ItemClicked
'******************************************************
' M_PlaceLayer.Text = StrAnsi(A)
PlaceOn.Text = StrAnsi(A)
If T Then
M_SelLayC(0).Enabled = True : M_SelLayC(1).Enabled = True
M_SelLayS(16).Enabled = True : M_SelLayS(17).Enabled = True
CompLayer(0).Enabled = True : CompLayer(1).Enabled = True
SolderLayer(16).Enabled = True : SolderLayer(17).Enabled = True
End If
'****************************************************
End Sub