|
-
Jul 29th, 2009, 04:30 AM
#1
Correct control for displaying Mouse right click menu?
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?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 04:49 AM
#2
Re: Correct control for displaying Mouse right click menu?
you need to assign the contextmenustrip to the control you're intending to use it with.
why do you need to change its location?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2009, 04:50 AM
#3
Re: Correct control for displaying Mouse right click menu?
ok i found the correct answer for re-locate the ContextMenuStrip control
Code:
ContextMenuStrip1.show(Me,100,100)
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 04:51 AM
#4
Re: Correct control for displaying Mouse right click menu?
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
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 04:51 AM
#5
Re: Correct control for displaying Mouse right click menu?
 Originally Posted by motil
ok i found the correct answer for re-locate the ContextMenuStrip control
Code:
ContextMenuStrip1.show(Me,100,100)
If you assign your ContextMenuStrip to the ContextMenuStrip of a control, e.g. a Button or a TextBox, then it will appear where the user right-clicks that control. Is that not what you want?
-
Jul 29th, 2009, 04:53 AM
#6
Re: Correct control for displaying Mouse right click menu?
 Originally Posted by jmcilhinney
If you assign your ContextMenuStrip to the ContextMenuStrip of a control, e.g. a Button or a TextBox, then it will appear where the user right-clicks that control. Is that not what you want?
yes i want to assign it to a TabControl, how do i do that ?
another question, is the ContextMenuStrip is a control?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 05:01 AM
#7
Re: Correct control for displaying Mouse right click menu?
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.
-
Jul 29th, 2009, 05:02 AM
#8
Re: Correct control for displaying Mouse right click menu?
in design time, click on your tabcontrol. you'll find the ContextMenuStrip property in the properties window
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2009, 05:04 AM
#9
Re: Correct control for displaying Mouse right click menu?
ok, i'm trying now what you guys suggested.
brb
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 05:07 AM
#10
Re: Correct control for displaying Mouse right click menu?
 Originally Posted by motil
yes i want to assign it to a TabControl, how do i do that ?
Set the ContextMenuStrip property of the control and select your ContextMenuStrip object from the drop-down list provided.
 Originally Posted by motil
another question, is the ContextMenuStrip is a control?
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.
-
Jul 29th, 2009, 05:12 AM
#11
Re: Correct control for displaying Mouse right click menu?
ok, my application dynamically create tabs, when a new tab is been created i assign the contextmenustring like this
Code:
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)
but the location is not changing correctly
what am i'm doing wrong?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 06:04 AM
#12
Re: Correct control for displaying Mouse right click menu?
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.
-
Jul 29th, 2009, 06:16 AM
#13
Re: Correct control for displaying Mouse right click menu?
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.
-
Jul 29th, 2009, 07:58 AM
#14
Re: Correct control for displaying Mouse right click menu?
 Originally Posted by jmcilhinney
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.
I'm sorry if i'm not making myself clear, in addition to the fact that my english is not that good my familiarity with .NET is also still in its beginning stage
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 09:08 AM
#15
Re: Correct control for displaying Mouse right click menu?
 Originally Posted by motil
I'm sorry if i'm not making myself clear, in addition to the fact that my english is not that good my familiarity with .NET is also still in its beginning stage 
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.
-
Jul 29th, 2009, 09:12 AM
#16
Re: Correct control for displaying Mouse right click menu?
so... you didn't answered... how many years are you programming ?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 09:20 AM
#17
Re: Correct control for displaying Mouse right click menu?
 Originally Posted by motil
so... you didn't answered... how many years are you programming ? 
From my profile:
Started programming at university in 1998 at the age of 28 and haven't stopped since.
-
Jul 29th, 2009, 09:33 AM
#18
Re: Correct control for displaying Mouse right click menu?
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.
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|