what is the correct control for displaying mouse event -> right click?
i tried the ContextMenuStrip control but it seems i can't change its location, can i?
Printable View
what is the correct control for displaying mouse event -> right click?
i tried the ContextMenuStrip control but it seems i can't change its location, can i?
you need to assign the contextmenustrip to the control you're intending to use it with.
why do you need to change its location?
ok i found the correct answer for re-locate the ContextMenuStrip control
Code:ContextMenuStrip1.show(Me,100,100)
even though i have the solution, How do I assign the contextmenustring to control?
as for your question: i want it to display a menu when the user right click on a control
and the location i need is the mouse.x mouse.y position which i already know how to acomplish
Every control has a ContextMenuStrip property. Assign your ContextMenuStrip control to that property, and it will appear at the correct location automatically. You do NOT need to handle the mouse click manually, or show the ContextmenuStrip manually.
You can see in the MSDN page that the ContextMenuStrip inherits from the Control class. So in that sense, yes, it is a control. I think it's kind of a special case though because it does not appear on the form as a usual control, but rather in the component tray (like the file dialogs).
The OpenFileDialog (for example) does not inherit from Control and hence is not a control.
in design time, click on your tabcontrol. you'll find the ContextMenuStrip property in the properties window
ok, i'm trying now what you guys suggested.
brb
Set the ContextMenuStrip property of the control and select your ContextMenuStrip object from the drop-down list provided.You don't need to ask us that. Open the MSDN Library and look at the documentation for the ContextMenuStrip class. Is the System.Windows.Forms.Control class in its inheritance hierarchy? If so then it's a control, otherwise it's not.
ok, my application dynamically create tabs, when a new tab is been created i assign the contextmenustring like this
but the location is not changing correctlyCode:
Dim newTab As New TabPage
newTab.ContextMenuStrip = ContextMenuStrip1
TabControl1.Width = "500"
TabControl1.Height = "500"
newTab.Controls.Add(newRichTextBox)
TabControl1.TabPages.Add(newTab)
TabControl1.SelectedIndex = tabsCounter
TabControl1.TabPages(TabControl1.TabPages.Count - 1).Controls.Add(newRichTextBox)
what am i'm doing wrong?
The TabPage is not the TabControl and vice versa. The tabs across the top are part of the TabControl, not the TabPages. You really need to explain exactly what you're trying to achieve so we don't have to guess.
It looks like you are trying to add a contextmenustrip to each tab header. Is that the case? If so, take a look at my signature. I have a codebank submission on a custom TabControl where each TabPage has a TabHeaderContextMenuStrip property. Set that property to your desired ContextMenuStrip, and it will display when you right-click the tab header.
A lot of people say that but even if you know nothing about programming you still know how you want your application to behave. End users know how to use software, even if they don't know how to create it. The problem is that people have an idea in their head of how their app should behave but they don't convey that when they post. If we have to guess what's required or make assumptions then there's every chance that the answers we give won't actually be to the question you want answered.
so... you didn't answered... how many years are you programming ?:p
Nice, your knowledge is really impressing, i have about 6 years of programming but with much simpler languages such asp classic,javascript,vbscript and other Net related lang, i just regret i didn't made the switch to .net much sooner as it looked very intimidating at start.