treeview using Contextmenu

toytoy

Well-known member
Joined
Jul 16, 2004
Messages
46
Programming Experience
1-3
Hi..

How to use the contextmenu to add and delete folders into the treeview during runtime.....

I am a bit blur...

can send me sample codes if any of you have solved it before for reference....

Thanks ;)
 
Hi

Currently i am doing the right click button for the treeview to add or remove folder, but i receive the error messages.... i try import these packages, also cannot worked....

Imports System
Imports System.Drawing
Imports System.Windows.Forms

The error are:

Value of type 'Integer' cannot be converted to 'System.Drawing.Point'. (for e.Y)

And

Too many arguments to 'Public Sub Show(control As System.Windows.Forms.Control, pos As System.Drawing.Point)'.
(for e.X)


Below is the code:

Private Sub trOwn_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles trOwn.MouseDown

'If the right button is down
If e.Button = MouseButtons.Right Then

'Find the item that was clicked on
contextMenuNode = trOwn.GetNodeAt(e.X, e.Y)

'If found, display the context menu
If Not IsNothing(contextMenuNode) Then
ContextMenu1.Show(trOwn, e.X, e.Y) ----- Error occur
End If
End If
End Sub

Anyway to resolved or improve....

Thanks
 
The Show method of the contextMenu requires a point structure as the second parameter. Try this:

VB.NET:
ContextMenu1.Show(trOwn, New Point(e.X, e.Y))
 
Back
Top