473,837 Members | 1,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Source object on right click

In VB 2005 I have six seperately named picture boxes (arranged in a table
layout control) in which I plot different X/Y data lines. I would like to be
able to right-click on a specific picture box (say, plot #3) and select a
different line color for that one plot.

How can I figure out which of the six plots is the one in question when
right-clicking on it? I can easily change the line color using the context
menu control, but I don't know which plot to apply to color change to. The
'sender' object does not give me any info from which picture box the click
event originated.

thanks
Jun 22 '06 #1
5 2128
I can think of two ways to do this:

To have a context menu for each picturebox and use the tag property to
write the name of the corresponding picturebox.

or

have one shared context menu among them. Handle the click event of that
menu item. cast the sender to a menu item and menuitem.owner is the
context menu. Now, you can get the location of the context menu and
compare it to the location of the picturebox. ie

if contextmenu.lef t > picturebox1.lef t and contextmenu.lef t <
picturebox1.rig ht and contextmenu.top > picturebox1.top and
contextmenu.top < picturebox1.bot tom then
' the right click was over picturebox1
else if ....

end if

I prefer the second way.

Ahmed
wxnut wrote:
In VB 2005 I have six seperately named picture boxes (arranged in a table
layout control) in which I plot different X/Y data lines. I would like to be
able to right-click on a specific picture box (say, plot #3) and select a
different line color for that one plot.

How can I figure out which of the six plots is the one in question when
right-clicking on it? I can easily change the line color using the context
menu control, but I don't know which plot to apply to color change to. The
'sender' object does not give me any info from which picture box the click
event originated.

thanks


Jun 23 '06 #2
Just tought of a third way,

You can handle the onenter event for each picture box. and once the
mouse enters the picture box you set a variable to the name of the
picture box ie
Private mouse As String

Private Sub NameToolStripMe nuItem_Click(By Val sender As
System.Object, ByVal e As System.EventArg s) Handles
NameToolStripMe nuItem.Click
MsgBox(mouse)
End Sub
Private Sub PictureBox1_Mou seEnter(ByVal sender As Object, ByVal e
As System.EventArg s) Handles PictureBox1.Mou seEnter
mouse = CType(sender.na me, PictureBox).Nam e
End Sub
wxnut wrote:
In VB 2005 I have six seperately named picture boxes (arranged in a table
layout control) in which I plot different X/Y data lines. I would like to be
able to right-click on a specific picture box (say, plot #3) and select a
different line color for that one plot.

How can I figure out which of the six plots is the one in question when
right-clicking on it? I can easily change the line color using the context
menu control, but I don't know which plot to apply to color change to. The
'sender' object does not give me any info from which picture box the click
event originated.

thanks


Jun 23 '06 #3
wxnut wrote:
How can I figure out which of the six plots is the one in question when
right-clicking on it? I can easily change the line color using the context
menu control, but I don't know which plot to apply to color change to. The
'sender' object does not give me any info from which picture box the click
event originated.


Do all 6 picture boxes share the same click method? If so, then the
sender is the picture box that was clicked. You just need to check
which one it is by casting the sender to PictureBox:

Dim pb As PictureBox = DirectCast(send er, PictureBox)

Or use the 'is' operator:

If sender is PictureBox1 Then
'do something
End If

Jun 23 '06 #4
Your code won't work. The sender is not the picturebox in this case
because he is using a contextmenu. The sender would be a menuitem.

Chris Dunaway wrote:
wxnut wrote:
How can I figure out which of the six plots is the one in question when
right-clicking on it? I can easily change the line color using the context
menu control, but I don't know which plot to apply to color change to. The
'sender' object does not give me any info from which picture box the click
event originated.


Do all 6 picture boxes share the same click method? If so, then the
sender is the picture box that was clicked. You just need to check
which one it is by casting the sender to PictureBox:

Dim pb As PictureBox = DirectCast(send er, PictureBox)

Or use the 'is' operator:

If sender is PictureBox1 Then
'do something
End If


Jun 23 '06 #5
Ahmed wrote:
Your code won't work. The sender is not the picturebox in this case
because he is using a contextmenu. The sender would be a menuitem.


The ContextMenu class has a SourceControl property which tells which
control the menu was invoked against. That should tell which picture
box the menu was clicked on.

Jun 26 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2899
by: Nancy | last post by:
Hi, Guys, I don't know why I can't view some webpages source code by click "View->Source" menu of Browser. These webpage source code can be viewed in same way by using other computers. My OS is Win Xp and Browser is IE6.0. I don't use any fire wall. Appreciate any hint. Nancy
115
14219
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i prefer a solution that (also) supports Windows. On the net I found a number of products that i looked at, but none of them gave me the impression of a serious candidate at this moment (KNoda, Gnome DB Manager, InterBase...). 2 additional...
5
2889
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1. I open a new project based on a windows form 2. I click on "data" and then "Add New Data Source" then I click on next within the wizard 3. I have 3 choices Database, Local Database, Web service and Object. 4. I choose Database, click next and get...
8
2479
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!! This is the error: biopsy.searchsubject.btnSubject_Click(Object Sender, EventArgs e) in C:\INetPub\WWWRoot\biopsy\searchsubject.aspx.vb:198 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
2
2394
by: Crimson* | last post by:
I've got a table with an entry type as "OLE Object" in Access 2003. In the form that the table is linked to I want to insert an image (BMP) for each record. However, when I attempt to do so the file is inserted and the filename (image.bmp) is inserted in the box with it taking up about half of the box. I didn't have this problem in Access XP. I've tried embedding and linking the file, but this always happens. Can anyone offer any...
2
2175
by: DBC User | last post by:
I have a project staged in source safe. What is the right way to open the project from source safe and get all the depended files on to my local pc? I do not have the project locally in my PC. I am trying to get it in a right way. Thanks in advance for the help.
12
11160
by: mistral | last post by:
Can anybody tell me how to get source code of page in iframe? (popup window is clickable image). When I right click on this popup border to view source, i see just as follows <html> <head> <title>New offer!</title> </head> <body style="margin-left: 0%; margin-right: 0%; margin-top: 0%;
1
2403
by: Coderer | last post by:
I have a project that I've been working on for a while, where several forms use DataGridViews to represent database information. The forms are .NET 2.0, in Studio 2005. For the past couple of days, whenever I click the little arrow in the top-right corner to show the DataGridView Tasks subwindow, then click to expand the dropdown for "Choose Data Source...", Studio crashes. If I "Debug" the app, of course I don't have any symbol tables,...
0
9843
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9682
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10628
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9406
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7807
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7004
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5670
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.