Visual Basic >
Visual Basic Forums
>
Visual Basic General
>
Error: Value of type 'Integer' cannot be converted to
Error: Value of type 'Integer' cannot be converted to
- Hi guys,
I have a problem, I cannot converted the value of Integer type, which it cannot converted to 'System.Drawing.Point' and 'System.Windows.Forms.Control' .
Both errors is highlighting on this statement
Form1.ContextMenu1.Show(Form1.MousePosition.X, MousePosition.Y)
Error I have received which the errors is highlighting on MousePosition.X and MousePosition.Y statement:
Value of type 'Integer' cannot be converted to 'System.Drawing.Point'
Value of type 'Integer' cannot be converted to 'System.Windows.Forms.Control'.
Class library code:
Public Class NoRightClickFlashControl Inherits AxShockwaveFlashObjects.AxShockwaveFlash Private Const WM_RBUTTONDOWN As Integer = &H204 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case m.Msg Case WM_RBUTTONDOWN Form1.ContextMenu1.Show(Form1.MousePosition.X, MousePosition.Y) m.Result = New IntPtr(1) Return End Select MyBase.WndProc(m) End Sub End Class
Form1 code:
Public Class Form1 Friend WithEvents ContextMenuStrip1 As System.Windows.Forms.ContextMenuStrip = New ContextMenuStrip Friend WithEvents PlayToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem Friend WithEvents StopToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem Friend WithEvents ForwardToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem Friend WithEvents ReverseToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
Please can you help me to solution the errors I have received on form1.contextmenu1.show statement??
Thanks,
Mark
Answers
It appears that you are trying to get the contextmenu to appear at the position the user has right clicked the mouse on the form. You do no need code to get the context menu to appear - simply set the form's context menu property to the context menu that you want to appear, For instance:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ContextMenuStrip = ContextMenuStrip1
End SubOr, you could set that property in the desinger.
- Marked As Answer byMark103 Saturday, November 07, 2009 11:31 PM
All Replies
- Change this line ....
Form1.ContextMenu1.Show(Form1.MousePosition.X, MousePosition.Y)
... to ...
Form1.ContextMenu1.Location = New Point(MousePosition.X, MousePosition.Y)
Form1.ContextMenu1.Show()
DJ PIP - Thanks for this, but I have received two errors in each line.
With this line:
Form1.ContextMenu1.Show()
Error: Overload resolution failed because no accessible 'Show' accepts this number of arguments.
And this line:
Form1.ContextMenu1.Location = New Point(MousePosition.X, MousePosition.Y)
Error: 'Location' is not a member of 'System.Windows.Forms.ContextMenu'.
Please can you help to fix this??
Thanks,
Mark
It appears that you are trying to get the contextmenu to appear at the position the user has right clicked the mouse on the form. You do no need code to get the context menu to appear - simply set the form's context menu property to the context menu that you want to appear, For instance:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ContextMenuStrip = ContextMenuStrip1
End SubOr, you could set that property in the desinger.
- Marked As Answer byMark103 Saturday, November 07, 2009 11:31 PM


