forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.vb
38 lines (30 loc) · 1.19 KB
/
source.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Option Explicit
Option Strict
Imports System.Data
Imports System.ComponentModel
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Protected textBox1 As TextBox
Protected pictureBox1 As TextBox
Protected contextMenu1 As ContextMenu
' <Snippet1>
Private Sub MyPopupEventHandler(sender As System.Object, e As System.EventArgs)
' Define the MenuItem objects to display for the TextBox.
Dim menuItem1 As New MenuItem("&Copy")
Dim menuItem2 As New MenuItem("&Find and Replace")
' Define the MenuItem object to display for the PictureBox.
Dim menuItem3 As New MenuItem("C&hange Picture")
' Clear all previously added MenuItems.
contextMenu1.MenuItems.Clear()
If contextMenu1.SourceControl Is textBox1 Then
' Add MenuItems to display for the TextBox.
contextMenu1.MenuItems.Add(menuItem1)
contextMenu1.MenuItems.Add(menuItem2)
ElseIf contextMenu1.SourceControl Is pictureBox1 Then
' Add the MenuItem to display for the PictureBox.
contextMenu1.MenuItems.Add(menuItem3)
End If
End Sub
' </Snippet1>
End Class