473,804 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_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

Dec 12 '06 #1
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

Dec 12 '06 #2

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

Dec 12 '06 #3

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

Similar topics

12
2389
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
14
3103
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
5
1820
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
27169
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))
1
2355
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
6
3246
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. ...
1
1482
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.
12
3606
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.
8
3138
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...
0
9572
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
10562
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, 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...
0
10319
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
10303
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
9132
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
7608
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
5508
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...
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
bsmnconsultancy
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...

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.