473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Graphics Query

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_MouseClick(object sender, MouseEventArgs
e,PaintEventArgs 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_MouseClick matches delegate
'System.Windows.Forms.MouseEventHandler'"

Can any one of you please tell me whts wrong in the code

Thanks In Advance
Poornima

Dec 12 '06 #1
2 1438
Hi Poornima,
the MouseEventHandler delegate does not take the PaintEventArgs parameter
you are trying to pass in the Form1_MouseClick 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_MouseClick(object sender, MouseEventArgs
e,PaintEventArgs 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_MouseClick matches delegate
'System.Windows.Forms.MouseEventHandler'"

Can any one of you please tell me whts wrong in the code

Thanks In Advance
Poornima

Dec 12 '06 #2

Mark R. Dawson wrote:
Hi Poornima,
the MouseEventHandler delegate does not take the PaintEventArgs parameter
you are trying to pass in the Form1_MouseClick 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_MouseClick(object sender, MouseEventArgs
e,PaintEventArgs 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_MouseClick matches delegate
'System.Windows.Forms.MouseEventHandler'"

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# .

Dec 12 '06 #3

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

Similar topics

12
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...
14
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...
5
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.
5
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...
1
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...
6
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...
1
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...
12
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
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,...
0
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,...

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.