Get Control That Was Clicked To Open A ContextMenuStrip?

Jan 15, 2010

I'm using a ContextMenuStrip for multiple controls and I'm trying to figure out the best way to get the control that was actually clicked on to open the Context Menu. The sender just gives the ToolStripMenuItem reference, which has an Owner property that references the ContextMenuStrip, but I cannot figure out how to tell which control the click came from. There must be a simple way to check this, right? I'm checking it in the ToolStripMenuItem's click event.

Friend WithEvents mnuWebCopy As System.Windows.Forms.ToolStripMenuItem
...
Private Sub mnuWebCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuWebCopy.Click

I found a similar post about this, but that mentions using a SourceControl property which I do not see on here.

I'm using Visual Studio 2008, VB.Net winforms.

View 3 Replies


ADVERTISEMENT

Implement A ContextMenuStrip And Take Action Based Upon Individual Element Right-clicked?

Jan 24, 2010

I have a TreeView with dynamically added nodes which I am using to actually contain textual data. I am using the tag field to contain special info for acting upon, based upon the node's tag. I have tried using treeview.SelectedNode.Tag. However, the selected node is the one most recently selected (like with a left mouse click), not the node I right-clicked. I have also tried using the contextmenustrip.SourceControl, but the source name for the control is always the container, the treeview control rather than the individual nodes. I have even tried associating my ContextMenuStrip dynamically to each individual node as it is added. The behavior is the same.A workable solution might be to cause a left-click when I do the right-click to bring up the context menu strip. I haven't been able to figure that one out yet either.

View 3 Replies

Customizing ContextMenuStrip Arrows And Open Direction?

Oct 14, 2010

Trying to create a custom button to reside on the desktop at:

Me.Height = PictureBox1.Height
Me.Width = PictureBox1.Width
Me.Top = My.Computer.Screen.WorkingArea.Height - Me.Height
Me.Left = My.Computer.Screen.WorkingArea.Width - Me.Width

The trouble is all the arrows point to right, and the menus open variably depending on size.

Is there anyway to make the arrows point left and make all menus open to left in same direction?

Also, Is it possible to make the width of my form autoresize to the size of a label and the image box, while keeping the imagebox at the bottom right of the screen showing the populated label to the left?

View 5 Replies

Can Get Web Browser To Open And Open File That Was Clicked On In Explorer?

Aug 7, 2011

I've noticed that when you click on a web page in Windows Explorer, or open a file in general, and the default application to open it is internet explorer, ie opens and opens the file. However, when I tried this on my Web Browser it opened, but ignored the file and went on its usual routine. How can I get my Web Browser to open and open the file that was clicked on in explorer?

View 1 Replies

.net - Control When A ContextMenuStrip Is Displayed?

Apr 9, 2010

In vb.net (2008), I want to be able to control when a contextMenuStrip (context menu) is displayed. I don't want it to always appear when the right mouse button is clicked...only when certain criteria within my program are met. I figure I would use addHandler but I'm not exactly clear on how to completely control the opening of the contextMenuStrip. I know I would issue a call to the "open" method to render the contextMenuStrip. However, I am unclear as to how to completely take over control of when to render the contextMenuStrip.

View 1 Replies

Get A ContextMenuStrip In Relation To The Parent Control It's Under?

Dec 30, 2009

I've made a ContextMenuStrip to use in my program to change the image in a picture box. However, it's used with multiple picture boxes which each need to have their own changed. What I want to do is make my command change only that picture box leaving the others as they were before. An example, if this were a plausible code.

Private Sub TestToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TestToolStripMenuItem.Click
Self(aka the control that currently has the menu open).Image = My.Resources.Picture
End Sub

View 2 Replies

[2005] Make Own Contextmenustrip For The Web Browser Control?

Sep 7, 2007

What I'm trying to do is make my own contextmenustrip for the web browser control, this menu has two items so far: "Select All" which will select all the text displayed and "Copy" which simply copies whatever text is highlighted or selected. No images are displayed so no need to worry about that.

Also I've noticed that whenever a file is dragged from windows and dropped onto the web browser control on my form, the browser simply displays the file (these are xml files that I'm dropping on the control, on my form) which is not what I want it to do, instead I want to grab the file path & name and use it elsewhere. The browser control doesn't have the DragEnter, DragDrop, DragLeave events like labels, forms, textboxes, etc... how would I handle this?

View 2 Replies

How To Display An Image In Picture Box Control When A Cell Clicked In Datagrid View Control

Jul 16, 2011

Im doing a mini project and i need to display an image in picture box control when a cell clicked in datagrid view control .the image is linked through the database ms access and im using vb.net frame work.

View 2 Replies

Get Clicked Link To Open Form

Jun 7, 2011

i have a webbrowser1 which cannot navigate from the link it is set up to, and cannot open new links in other windows, i need something like if get the URL Google.com when it clicked a link on the current site, then Form2.Show(). Link here <-- when clicked open form2 if its yahoo opens form3.

View 1 Replies

Get Instance When .exe Or Browser Is Clicked To Open?

Jun 7, 2011

Actually i am a PHP/Mysql developer.i am newbie to vb.net and i am trying to develop a application which asks for a password when the user tries to open any.exe file

for example:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[code].....

View 2 Replies

When Link Clicked Open In New Window?

Dec 12, 2009

When a user click a link that will open in a new window. I want it to open in my web browser. Not Internet Explorer.

View 9 Replies

.net - Open .chm File From Resources When A Buttons Clicked?

Jun 9, 2012

I already have this code from another question on this website.

Help.ShowHelp(ParentForm,
("C:UsersBeaudeanDesktopHelp.chm"),HelpNavigator.TableOfContents, Nothing)

That works fine except i need the location of the chm help file to point to "my.resources" where it exists because i need to install my program but in that code example it only works with strings?

View 1 Replies

Have One Form Close And Another Open When A Button Is Clicked?

Dec 13, 2010

I'm making an equation program and I want to have a main menu where the user can select an equation and then when one of the buttons is clicked, it closes the "selection" form and opens the appropriate form. For now I just have it set to show the proper form (for example, Form3.Show) but when I try to do something like Me.Close() after it, everything closes instead of keeping Form3 open.

View 2 Replies

Making App Open File That Is Double Clicked On

Aug 23, 2010

i've made a little app that opens .txt files kind of a replacement for notepad now i have set the install package in visual studio to associate .txt with my app however when i double click on .txt files my app opens but blank. so i'm assuming i've gotta code something to get it to open the clicked on file but.... haven't got a clue where to look for inspiration or code i can "borrow" and chop to fit my needs. i assume it's got to be in the load section of the program.[code]

View 6 Replies

Attch A File In .net Application,which Open From The Form On Clicked?

Jan 15, 2012

attch a file in .net application,which can open from the form on clicked..

View 4 Replies

How To Make A Web-browser Run / Open Files When Links Clicked On

Aug 8, 2011

Im making a "offline viewer" which uses saved webpages.I'm using a web browser and a tree-viewer. Currently when you click a link for a file/ installer (for example if you click on the "The Gimp" installer link) you have to right click, and then "save target as..." and then save it (so you would then two copys of the same file) AND then open it.Is there way i could have the file open when the link click? (Again, for example, the running of The Gimp installer apon clicked, or the opening of the video file when clicked)

View 8 Replies

WebBrowser - Open Links And Buttons When Clicked In New Window

Jul 11, 2011

I am trying to get my Visual Basic Web Browser to open links and buttons when clicked in a new window of my web browser by using the New Window event. I found this code to make links work in a new window of my browser, but buttons will not. When I click on a button, a new window of my form pop ups but the url says, "about:blank". Is it because the attribute is set to "href"?

Private Sub WebBrowser1_NewWindow2(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
Dim myElement As HtmlElement = WebBrowser1.Document.ActiveElement
Dim target As String = myElement.GetAttribute("href")
Dim newInstance As New Form1
newInstance.Show()
newInstance.WebBrowser1.Navigate(target)
e.Cancel = True

View 14 Replies

Ultimate Basic Coding - If I Just Clicked On The OpenFile Dialog It Wouldn't Open The File?

Aug 14, 2010

I'm trying to code some programs and i want to use something called " (its in the dialog menu) FileOpen.dialog" i think thats what its called. Anyway i was seeing that if i just clicked on the OpenFile dialog it wouldn't open the file. So i knew i needed a code. I just dont want the OpenFile dialog i was just using that for example.

View 6 Replies

VB 2008 - Create A Label That When Clicked By The User It Will Open A Website Using The Default Browser?

Jun 12, 2011

how do I create a label that when clicked by the user, it will open a website using the default browser. I have seen the control LinkLabel but I do not know how it works or how to use it.

View 3 Replies

How To Determine Which Control Has Been Clicked

Apr 11, 2011

I have a program with 32 PictureBoxes (pb1 ... pb32). The user will select one of the picture boxes. All picture boxes will call the same subroutine, passing the variable of the name of the box clicked. Rather than writing a click event for all 32 boxes, and call the same subroutine from each event, is there a way that I can determine which picture box has been clicked?

View 3 Replies

Run Code Until A Control Is Clicked?

Aug 24, 2010

I want to run a piece of code on the timer tick event until the user clicks 'button 1'?

View 3 Replies

Determine If ANY Control On Screen Was Clicked?

Jun 6, 2011

Is there a way to determine is any control at all on a form has gotten focus? I know you can individually determine if a single control has focus or has been clicked, etc. but is there an event that can tell you that some/any control has been clicked?

i.e.
Private Sub myFrm_Magic(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.SomethingClicked
Msgbox(Me.ActiveControl.Name)
End Sub

View 1 Replies

Capture Clicked Word In RTF Control In 2010?

Aug 13, 2011

I have a rich text box control in my form. Much like Concise Oxford Dictionary, when user clicks on any word, I need to capture it and process it. The click event don't help and I can't seem to figure it out.

View 3 Replies

Hide A User Control When A Button Is Clicked?

Nov 28, 2011

How do you hide a user control when a button is clicked? I know how to hide a form but not a control. If it is possible to actually remove the usercontrol from the panel that would be awesome to and then have it show again once I click the other Icon. [cod]e...

View 39 Replies

Which HTML Element Is Clicked In WEB-BROWSER CONTROL

Jun 11, 2009

WHen we click on site whether left click or right....Control goes to IEDoc_MouseDown event,I just want to ask is that possible to know taht which element is clicked..Suppose we right click on link,is that possible to know it that link is clicked.[code]

View 1 Replies

VB 2010 - Get The Links That Open In A New Window To Open In Main Webbrowser Control?

Mar 11, 2010

Private Sub LinkClicked(ByVal sender As Object, ByVal e As EventArgs)
Dim link As HtmlElement = WebBrowser1.Document.ActiveElement
Dim url As String = link.GetAttribute("href")
[code]...

Okay so here's the question how do I get the links that open in a new window to open in my main webbrowser control. The above code does some, but it's not fool proof.

View 1 Replies

Forms :: Which HTML Element Is Clicked In WEBBROWSER CONTROL

Jun 11, 2009

WHen we click on site whether left click or right....Control goes to IEDoc_MouseDown event,I just want to ask is that possible to know taht which element is clicked..Suppose we right click on link,is that possible to know it that link is clicked.

Public Class Form2
Dim WithEvents IEDoc As System.Windows.Forms.HtmlDocument
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs)

[Code].....

View 5 Replies

Tell What Form Control A Context Menu Was Over When Clicked One Of Its Items

Mar 22, 2011

I have 10 textboxes on a windows form. Each textbox has the same contextmenu. Say they are named textbox1 - textbox10. What I need is when I right click in one of the textboxes I need to capture the name of the textbox in which the contextmenu was called. So if I am over textbox2 and right click for contextmenu then select menu item #2 in the click event I need to capturethe textbox control I called the contextmenu from (textbox2) so I can send that name to a function to process my other code.

View 2 Replies

User Control To Disappear When Another Item From Menustrip Is Clicked?

Jun 12, 2011

how can i disable from the panel the user control if another user control is selected from menustrip???

here is my code at the moment
Private Sub LabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LabToolStripMenuItem.Click

[Code]......

View 3 Replies

VS 2005 Which HTML Element Is Clicked In WEBBROWSER CONTROL

May 7, 2009

WHen we click on site whether left click or right....Control goes to IEDoc_MouseDown event,I just want to ask is that possible to know taht which element is clicked..Suppose we right click on link,is that possible to know it that link is clicked.

Public Class Form2
Dim WithEvents IEDoc As System.Windows.Forms.HtmlDocument
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

[code]....

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved