Hello,
I have a mouse click event in which i need to draw a line if the mouse
was clicked within specified co-ordinates.I wrote the following code
private void Form1_MouseClic k(object sender, MouseEventArgs
e,PaintEventArg s pe)
{
Graphics mclkDl = pe.Graphics;
Pen dashPen = new Pen(Color.Gray, 1);
tbMouseX.Text = "The X-cordinate is " + MousePosition.X ;
tbMouseY.Text = "The Y-cordinate is " + MousePosition.Y ;
nMouseX = MousePosition.X ;
nMouseY = MousePosition.Y ;
if(nMouseX >= 50 && nMouseY == 169)
mclkDl.DrawLine (dashPen, 50, 80, 169, 80);
}
but it gave an error saying
"No Overload for form1_MouseClic k matches delegate
'System.Windows .Forms.MouseEve ntHandler'"
Can any one of you please tell me whts wrong in the code
Thanks In Advance
Poornima 2 1458
Hi Poornima,
the MouseEventHandl er delegate does not take the PaintEventArgs parameter
you are trying to pass in the Form1_MouseClic k method signature. If you want
to draw on the mouse click you are going to need to create a Graphics object
and create a class level field that you can use to draw to.
Mark.
-- http://www.markdawson.org
"Poornima" wrote:
Hello,
I have a mouse click event in which i need to draw a line if the mouse
was clicked within specified co-ordinates.I wrote the following code
private void Form1_MouseClic k(object sender, MouseEventArgs
e,PaintEventArg s pe)
{
Graphics mclkDl = pe.Graphics;
Pen dashPen = new Pen(Color.Gray, 1);
tbMouseX.Text = "The X-cordinate is " + MousePosition.X ;
tbMouseY.Text = "The Y-cordinate is " + MousePosition.Y ;
nMouseX = MousePosition.X ;
nMouseY = MousePosition.Y ;
if(nMouseX >= 50 && nMouseY == 169)
mclkDl.DrawLine (dashPen, 50, 80, 169, 80);
}
but it gave an error saying
"No Overload for form1_MouseClic k matches delegate
'System.Windows .Forms.MouseEve ntHandler'"
Can any one of you please tell me whts wrong in the code
Thanks In Advance
Poornima
Mark R. Dawson wrote:
Hi Poornima,
the MouseEventHandl er delegate does not take the PaintEventArgs parameter
you are trying to pass in the Form1_MouseClic k method signature. If you want
to draw on the mouse click you are going to need to create a Graphics object
and create a class level field that you can use to draw to.
Mark.
-- http://www.markdawson.org
"Poornima" wrote:
Hello,
I have a mouse click event in which i need to draw a line if the mouse
was clicked within specified co-ordinates.I wrote the following code
private void Form1_MouseClic k(object sender, MouseEventArgs
e,PaintEventArg s pe)
{
Graphics mclkDl = pe.Graphics;
Pen dashPen = new Pen(Color.Gray, 1);
tbMouseX.Text = "The X-cordinate is " + MousePosition.X ;
tbMouseY.Text = "The Y-cordinate is " + MousePosition.Y ;
nMouseX = MousePosition.X ;
nMouseY = MousePosition.Y ;
if(nMouseX >= 50 && nMouseY == 169)
mclkDl.DrawLine (dashPen, 50, 80, 169, 80);
}
but it gave an error saying
"No Overload for form1_MouseClic k matches delegate
'System.Windows .Forms.MouseEve ntHandler'"
Can any one of you please tell me whts wrong in the code
Thanks In Advance
Poornima
Hello Mark
Thank you but can you explain me with an example code because iam new
to C# . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sanjay |
last post by:
hi,
We are currently porting our project from VB6 to VB .NET.
Earlier we used to make scale transformations on objects like pictureBox ,
forms etc.Now Such transformations are made on the graphics object of the
form/pictureBox.
Should It be better if make a graphics object from my pictureBox in load
event handler of the form and store it as member variable of the form , make
|
by: Pmb |
last post by:
At the moment I'm using Borland's C++
(http://www.borland.com/products/downloads/download_cbuilder.html#)
I want to be able to take an array of points and plot them on the screen. Is
there a way to do this? E.g. I want to be able to graph a function. At this
point I'm not up to a level in C++ where I want to start learning Visual C++
so I don't want to go that route.
Thanks
|
by: not_obfuscatory |
last post by:
Hi group. I'm wondering about any books/resources for graphics, etc,
in C. I'm particularly interested in the GUI aspect. I have no
experience in this. Thank you.
|
by: Charles A. Lackman |
last post by:
Hello,
I have created a complete PrintDocument and need to create an image from it.
How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.DrawString(Line1.Text, FontLine1, TheBrush, Thelocation1, 390 +
yPos, AStringFormat)
e.Graphics.DrawString(Line2.Text, FontLine2, TheBrush, Thelocation2,
TheHeight1 + (390 + yPos))
|
by: rushikesh.joshi |
last post by:
Hi All,
I want some charting functionality in my ASP.NET application.
I want to show a multiple bar on my web page. It's based on down time
of different servers.
like
server1: down betn 4 AM to 5 AM and 6 PM to 7 PM
server2: down betn 7 AM to 7:30 AM
server3: down betn 3 AM to 5 AM and 2 Pm to 3 PM
| |
by: Chris Dunaway |
last post by:
The method for printing documents in .Net can be confusing, especially
for newer users. I would like to create a way to simplify this
process. My idea would be implemented using a PrintDocument (much like
the current model), but my PrintDocument would have a Pages collection
such that each time you need to have an additional page, you would just
add another page to the collection and then use the page object for the
actual drawing etc. ...
|
by: James Willmott |
last post by:
If I have a question, about how to implement a graphics algorithm in
C++, but not specifically related to getting the graphics on screen
(that I can work out for myself). Would asking for help in the
implemention ( asking things like whether I should use std::vector vs
std::list for example ) be off topic here?
Thanks,
jw.
|
by: Xah Lee |
last post by:
Of Interest:
Introduction to 3D Graphics Programing
http://xahlee.org/3d/index.html
Currently, this introduction introduces you to the graphics format of
Mathematica, and two Java Applet utilities that allows you to view them
with live rotation in a web browser. Also, it includes a introductory
tutorial to POV-Ray.
|
by: Abhiraj Chauhan |
last post by:
I need someone to make an example of how to create a graphics window in VB.net 2008.
I understand the basics of how to draw a rectangle and lines etc.
What I need is an example of how to make a window that goes in a form that does the following:
1. When the application is run, the form has a graphics area within the form (not the entire form) colored white.
2. Two text boxes (not in the graphics area) for data entry used to define...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |