Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Small Problemo With Drawing :p


  • Please log in to reply
7 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:05:32 PM

Posted 06 October 2008 - 11:08 AM

i have been researching how to draw using pixels etc and i found this, after looking at it alot, writing it out and having my mind boggled i just couldent fix this problem...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestPaint
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		protected override void OnPaint(PaintEventArgs e)
		{
			// Get the graphics object
			Graphics gfx = paintEvnt.Graphics; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<HERE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
			// Create a new pen that we shall use for drawing the line
			Pen myPen = new Pen(Color.Black);
			// Loop and create a new line 10 pixels below the last one
			for (int i = 20; i < 250; i = i + 10)
			{
				gfx.DrawLine(myPen, 20, i, 270, i);
			} 
		}
	}
}

'paintEvnt' is underligned in red with the caption "The name 'paintEvnt' dose not exist in the current context"
So do i have to declaire it? if so, how?

BC AdBot (Login to Remove)

 


m

#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:11:32 AM

Posted 06 October 2008 - 04:53 PM

That is because you have no object called paintEvnt anywhere, and you are trying to call a function of it. Look at the code you copied, and then look at your code. You didn't copy it correctly.

#3 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:05:32 PM

Posted 07 October 2008 - 10:16 AM

But there isnt anything that uses it in the example? well, anything that i can see.

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:11:32 AM

Posted 07 October 2008 - 12:28 PM

Where in the code on that page do you find the following: (Except for in the incorrect code that you posted as acomment on the end of the page)

This is code you wrote-> protected override void OnPaint(PaintEventArgs e)

??

#5 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:05:32 PM

Posted 07 October 2008 - 02:23 PM

Whoh...this is a "whu whu whuuu" moment...i see now its not 'e'. the paintEvnt is declaired there. im going to chasnge it now and see what happens...

#6 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:05:32 PM

Posted 07 October 2008 - 02:28 PM

You where right, it worked, now i need to learn how to do them anywhere on the form, diagonnaly etc and on mouce click it draws.
Thanks, Wolfy87.

#7 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:11:32 AM

Posted 07 October 2008 - 08:03 PM

Which is what I told you in the second post......... :thumbsup:

#8 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:05:32 PM

Posted 08 October 2008 - 10:02 AM

I know you did and sorry but i just didnt understand where i was supposed to put it and i didnt realie i had missed it out but still many thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users