c#


How can I use the MouseEventArgs in another method?


I have a picture box which I need to get the values of the mouse position within the box once the mouse is clicked in it. I can do this using this code:
public void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
int CurX;
int CurY;
CurX = e.X;
CurY = e.Y;
}
I now need to use those values CurX and CurY to convert them onto relative positions of the picture box ie the four corners of the picture box have GPS Lat and Long coordinates so the approximate Lat and Long can be calculated from the position of the mouse event click in the picture box.
The calculated values are checked against an array in another method and values selected from the array based on the approximate Lat and Long values.
How can I get these CurX and CurY values from pictureBox1_MouseClick to another method and then use another MouseClick event and repeat the process?
Many thanks Steve
Use:
private int curX;
private int curY;
public void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
curX = e.X;
curY = e.Y;
}
Then you can use curX a curY at other places in the class
Use global variables. Assign the values to them and access anywhere in your class.

Related Links

c# Copying jagged arrays to strings
How transfer to AddBindings() in NinjectDependencyResolver concrete type argument from MVC controller class?
Pointer based on type parameter
Entity Framework 6 auto compiled queries
Windows Store App Access Violation Exception only on Windows 10
How to hide rows in a datagridview column in C# SQL visual studio windows form
WinForm DPI issue
Generic interface/base class - access members without type constraints
error CS0120: An object reference is required to access non-static member `questgiver.iscompleted_questgiver' [duplicate]
Infragistics Dll reference Wrong Dll
Using Awesomium (x86) and OSK (x64) in the Same Any CPU App
App Settings not showing up after loading a app.config file with configuration manager
c# Mongodb 2.0 driver get UpdateManyAsync result
Cannot Get Facebook Profile Picture Using www in Unity Facebook SDK
Prevent Android AlertDialog from closing when neutral button is pressed
Keep entity-references clean without saving to database

Categories

HOME
azure-documentdb
virtual-machine
reference
ebay-api
arcgis
boxplot
django-middleware
checkpoint
multipartform-data
comments
gnuradio
qt4
soap-client
ndepend
point-of-sale
solidity
desktop-application
yui
jsfiddle
versioning
smooth-scrolling
google-street-view
udeploy
glibc
sonarlint
openoffice-basic
serenity-js
utc
bytebuffer
edirectory
drawrect
exacttarget
snapkit
fastadapter
intersection
ssdp
irr
grails-2.0
logan-square
nao-robot
pyopenssl
serialversionuid
cloudconvert
catalyst
breadcrumbs
optional-parameters
papyrus
visual-web-developer
normalisation
change-password
bytearray
weblogic-maven-plugin
avaudiorecorder
jcalendar
firefox-os
app-data
edgar
textblob
opennebula
shunting-yard
static-files
jsonmodel
system.net
xts
amzi-prolog
email-headers
facebook-java-api
mahara
svg-android
jfilechooser
friendly-id
symbian3
bho
ntdll
moonscript
quit
invalidoperationexception
orchestration
mail-gem
bash4
facebook-winjs-sdk
ruby-1.9
automapper-2
vectorwise
pkcs#7
coderush-xpress
zend-acl
disk-based
weak-typing

Resources

Encrypt Message