drawimage help please
Post your questions regarding programming in C# in here.
4 posts
Page 1 of 1
it seems that this won't work :(
what are we doing wrong even i have no clue it seems working fine in vb.net this way but not in c#
what are we doing wrong even i have no clue it seems working fine in vb.net this way but not in c#
Code: Select all
Error is
if (_clicked == false)
{
g.DrawImage(pictureBox2.Image, new Rectangle(0, 0, 39, 41));
}
else
{
g.DrawImage(pictureBox1.Image, new Rectangle(0, 0, 39, 41));
}
System.NullReferenceException was unhandledthank you
Message=Object reference not set to an instance of an object.
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Make sure that g is initialized like so
Code: Select all
And pictureBox1 and pictureBox2 have an image set. And also try not to draw images in DesignMode (it tends to slow down the Designer).Graphics g = e.Graphics;
//-- Or like this
Graphics g = this.CreateGraphics();
Last edited by XTechVB on Wed Feb 12, 2014 8:52 pm, edited 2 times in total.
You can find me on Facebook or on Skype mihai_92b
make sure you have this at the very top of your class code, then everything else below it.
Code: Select all
public Form1()
{
InitializeComponent();
}
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
thanks you #smashapps this did the job 

visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023