MENU
Posted: Thu May 13, 2021 5:53 pm
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents M As ContextMenuStrip
Friend WithEvents m_item As ToolStripMenuItem
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
menuyap.show
End Sub
Private Sub Report_Click(sender As Object, e As EventArgs) Handles Me.Click
menuyap.show(MousePosition)
End Sub
Function menuyap()
Dim m As ContextMenuStrip
Dim m_item As New System.Windows.Forms.ToolStripMenuItem ': AddHandler my.Items.Click, AddressOf my_clicked
m = New System.Windows.Forms.ContextMenuStrip(Me.components)
AddHandler m_item.Click, AddressOf m_clicked
m.Name = "m"
m.Text = "menü"
m.Items.Add("satir 1") : AddHandler m.Click, AddressOf m_clicked 'normal satır
m.Items(m.Items.Count - 1).Name = "satir1"
m_item.Name = "satir2" 'altı olan satır
m_item.Text = "satir 2"
m_item.DropDownItems.Add("satir alt")
m_item.DropDownItems(m_item.DropDownItems.Count - 1).Name = "satiralt1" : AddHandler m_item.DropDown.Click, AddressOf ma_clicked
m_item.DropDownItems.Add("satir alt 2") : AddHandler m_item.DropDown.Click, AddressOf ma_clicked
m_item.DropDownItems(m_item.DropDownItems.Count - 1).Name = "satiralt2"
m.Items.AddRange(New System.Windows.Forms.ToolStripItem() {m_item}) ': AddHandler m.Click, AddressOf m_clicked
m.ResumeLayout(False)
Return m
End Function
Sub m_clicked(sender As Object, e As EventArgs) Handles m_item.DropDownItemClicked 'm_item.DropDownItemClicked 'm_item.Click
'Me.Text = sender.ToString
'e.ToString 'TryCast(sender, ToolStripDropDownItem).Text
End Sub
Sub ma_clicked(sender As Object, e As EventArgs) Handles m_item.Click
'Me.Text = "down" & e.ToString
Me.Text = TryCast(sender, ToolStripItem).Text
End Sub
Private Sub CENC_Click(sender As Object, e As EventArgs) Handles CENC.Click
MsgBox(TryCast(sender, ToolStripMenuItem).Text)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MEN.Show(MousePosition)
End Sub
end class
Inherits System.Windows.Forms.Form
Friend WithEvents M As ContextMenuStrip
Friend WithEvents m_item As ToolStripMenuItem
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
menuyap.show
End Sub
Private Sub Report_Click(sender As Object, e As EventArgs) Handles Me.Click
menuyap.show(MousePosition)
End Sub
Function menuyap()
Dim m As ContextMenuStrip
Dim m_item As New System.Windows.Forms.ToolStripMenuItem ': AddHandler my.Items.Click, AddressOf my_clicked
m = New System.Windows.Forms.ContextMenuStrip(Me.components)
AddHandler m_item.Click, AddressOf m_clicked
m.Name = "m"
m.Text = "menü"
m.Items.Add("satir 1") : AddHandler m.Click, AddressOf m_clicked 'normal satır
m.Items(m.Items.Count - 1).Name = "satir1"
m_item.Name = "satir2" 'altı olan satır
m_item.Text = "satir 2"
m_item.DropDownItems.Add("satir alt")
m_item.DropDownItems(m_item.DropDownItems.Count - 1).Name = "satiralt1" : AddHandler m_item.DropDown.Click, AddressOf ma_clicked
m_item.DropDownItems.Add("satir alt 2") : AddHandler m_item.DropDown.Click, AddressOf ma_clicked
m_item.DropDownItems(m_item.DropDownItems.Count - 1).Name = "satiralt2"
m.Items.AddRange(New System.Windows.Forms.ToolStripItem() {m_item}) ': AddHandler m.Click, AddressOf m_clicked
m.ResumeLayout(False)
Return m
End Function
Sub m_clicked(sender As Object, e As EventArgs) Handles m_item.DropDownItemClicked 'm_item.DropDownItemClicked 'm_item.Click
'Me.Text = sender.ToString
'e.ToString 'TryCast(sender, ToolStripDropDownItem).Text
End Sub
Sub ma_clicked(sender As Object, e As EventArgs) Handles m_item.Click
'Me.Text = "down" & e.ToString
Me.Text = TryCast(sender, ToolStripItem).Text
End Sub
Private Sub CENC_Click(sender As Object, e As EventArgs) Handles CENC.Click
MsgBox(TryCast(sender, ToolStripMenuItem).Text)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MEN.Show(MousePosition)
End Sub
end class