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
I have a problem to get unique values from dateperiod-loop.
There is a tons of examples how to do it, but after hours of searching, i couldn't find suitable ...
Good man James helped me learn die roll board game programming in Java,
and I applied it on Ladders and Snakes. Made one in Java. Now I'm learning to do ...
Hello everyone hope you are doing well, i was busy these days i was having problem with the police in my country, they catch me smoking weed and now i ...