我想在vb.net中创建一个自定义控件,其行为类似于vb6 popupmenu&它就像表单显示对话框一样。弹出菜单动态填充&我的O / P仅取决于popupmenu的点击事件结果。
通过使用上下文menustrip问题是在调用上下文menustrip的所有形式事件之后引发上下文menustrip的click事件。因此,我无法使用上下文menustrip itemclicked结果继续在Mainform中继续部分程序。
我的主要表格MouseUp被称为
显示内部鼠标上下文菜单
显示上下文菜单后删除主表单MouseUp的下一行继续从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