i have a tool strip button for bookmarks like the one in Mozilla fire fox or google chrome, i can add button and i can click it but i cant remove it , because that i added context menu to the tool strip with remove, so i want the code for removing the selected tool strip button .
The following code (courtesy of: this post) will hopefully help.
First, add a class level variable to store the button that was clicked (i.e. the one to be removed from the tool strip.
Dim clickedButton As ToolStripItem = Nothing
Then add the following code to the Opening event of your context menu. This code attempts to identify the button that was clicked when the prior to the context menu being displayed:
Private Sub ContextMenuStrip1_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening Dim strip As ToolStrip = TryCast(ContextMenuStrip1.SourceControl, ToolStrip) clickedButton = Nothing If strip IsNot Nothing Then Dim position As Point = strip.PointToClient(MousePosition) For Each item As ToolStripItem In strip.Items If item.Bounds.Contains(position) Then clickedButton = item Next End If End Sub
Finally, in your remove menu item, add the following code to remove the actual button:
Private Sub RemoveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RemoveToolStripMenuItem.Click If clickedButton IsNot Nothing Then ToolStrip1.Items.Remove(clickedButton) End Sub
thank you very much you don't know how much you helped me
A person starts out as the "Curator" and stands at the end of a field. Everyone else playing stands at the far end (distance depends upon playing area selected). The ...
I am currently working on a program to track my mile for my monthly expense report for work. Everything is working great, however, I can not for the life of ...
I am trying to understand the SynchronizedMap and I ran the below code. I get the below Output with an exception. According to my understanding the exception is caused when ...