Hello, (total GDI newbie)
I'm having trouble drawing just a simple line to display in a picturebox. I
just want a straight, dotdash line.
I have two methods, one works and one doesn't (it cause an exception to be
thrown):
This one works but it's not the results I want.
private void CreateImage1()
{
Bitmap b = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(b);
g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height));
pb1.Image = b;
g.Dispose();
}
This one cause the exception to be thrown:
private void CreateImage()
{
Bitmap bmp = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bmp);
Pen p = new Pen(Color.AliceBlue, 2);
p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
Point p1 = new Point(pb1.Left);
Point p2 = new Point(pb1.Right);
g.DrawLine(p, p1, p2);
pb1.Image = bmp;
g.Dispose();
bmp.Dispose();
}
Anybody know what I'm having these problems?
I appreciate your help btw.
Steve 9 2390
Don't dispose of bmp at the end of your second example.
--
Bob Powell [MVP]
C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm
"Steve Long" <No***************@co.clark.wa.us> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl... Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox.
I just want a straight, dotdash line.
I have two methods, one works and one doesn't (it cause an exception to be thrown):
This one works but it's not the results I want. private void CreateImage1() { Bitmap b = new Bitmap(100, 100); Graphics g = Graphics.FromImage(b); g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height)); pb1.Image = b; g.Dispose(); }
This one cause the exception to be thrown: private void CreateImage() { Bitmap bmp = new Bitmap(100, 100); Graphics g = Graphics.FromImage(bmp); Pen p = new Pen(Color.AliceBlue, 2); p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; Point p1 = new Point(pb1.Left); Point p2 = new Point(pb1.Right); g.DrawLine(p, p1, p2); pb1.Image = bmp; g.Dispose(); bmp.Dispose(); }
Anybody know what I'm having these problems?
I appreciate your help btw. Steve
Don't dispose of bmp at the end of your second example.
--
Bob Powell [MVP]
C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm
"Steve Long" <No***************@co.clark.wa.us> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl... Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox.
I just want a straight, dotdash line.
I have two methods, one works and one doesn't (it cause an exception to be thrown):
This one works but it's not the results I want. private void CreateImage1() { Bitmap b = new Bitmap(100, 100); Graphics g = Graphics.FromImage(b); g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height)); pb1.Image = b; g.Dispose(); }
This one cause the exception to be thrown: private void CreateImage() { Bitmap bmp = new Bitmap(100, 100); Graphics g = Graphics.FromImage(bmp); Pen p = new Pen(Color.AliceBlue, 2); p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; Point p1 = new Point(pb1.Left); Point p2 = new Point(pb1.Right); g.DrawLine(p, p1, p2); pb1.Image = bmp; g.Dispose(); bmp.Dispose(); }
Anybody know what I'm having these problems?
I appreciate your help btw. Steve
Bob,
Thanks for your response. That does indeed stop the exception from being
thrown but the bitmap still doesn't display. I'm calling the method in the
form_paint event. Any idea why I'm not seeing the image?
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:#W**************@TK2MSFTNGP10.phx.gbl... Don't dispose of bmp at the end of your second example.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eX**************@TK2MSFTNGP10.phx.gbl... Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a
picturebox. I just want a straight, dotdash line.
I have two methods, one works and one doesn't (it cause an exception to
be thrown):
This one works but it's not the results I want. private void CreateImage1() { Bitmap b = new Bitmap(100, 100); Graphics g = Graphics.FromImage(b); g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height)); pb1.Image = b; g.Dispose(); }
This one cause the exception to be thrown: private void CreateImage() { Bitmap bmp = new Bitmap(100, 100); Graphics g = Graphics.FromImage(bmp); Pen p = new Pen(Color.AliceBlue, 2); p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; Point p1 = new Point(pb1.Left); Point p2 = new Point(pb1.Right); g.DrawLine(p, p1, p2); pb1.Image = bmp; g.Dispose(); bmp.Dispose(); }
Anybody know what I'm having these problems?
I appreciate your help btw. Steve
I would recommend using the PaintEventArgs object directly instead of
creating your own Graphics object and disposing of it... Putting the code
directy in the paint method, the code would look like:
private void pb1_Paint(object sender, System.Windows.Forms.PaintEventArgs
e)
{
Pen p = new Pen(Color.AliceBlue, 2);
p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
Point p1 = new Point(pb1.Left);
Point p2 = new Point(pb1.Right);
e.Graphics.DrawLine(p, p1, p2);
}
If you want a separate method to draw the line, just pass in the
PaintEventArgs, or the Graphics object to the method, "CreateImage".
Some MSDN articles that might help:
Good luck!
Pete Hauge, Visual C# Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
-------------------- From: "Steve Long" <No***************@co.clark.wa.us> References: <eX**************@TK2MSFTNGP10.phx.gbl>
<#W**************@TK2MSFTNGP10.phx.gbl>Subject: Re: Help drawing a line Date: Mon, 6 Oct 2003 08:41:23 -0700 Lines: 70
Bob, Thanks for your response. That does indeed stop the exception from being thrown but the bitmap still doesn't display. I'm calling the method in the form_paint event. Any idea why I'm not seeing the image?
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:#W**************@TK2MSFTNGP10.phx.gbl... Don't dispose of bmp at the end of your second example.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eX**************@TK2MSFTNGP10.phx.gbl... > Hello, (total GDI newbie) > I'm having trouble drawing just a simple line to display in apicturebox. I > just want a straight, dotdash line. > > I have two methods, one works and one doesn't (it cause an exception to be > thrown): > > This one works but it's not the results I want. > private void CreateImage1() > { > Bitmap b = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(b); > g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height)); > pb1.Image = b; > g.Dispose(); > } > > This one cause the exception to be thrown: > private void CreateImage() > { > Bitmap bmp = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(bmp); > Pen p = new Pen(Color.AliceBlue, 2); > p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; > Point p1 = new Point(pb1.Left); > Point p2 = new Point(pb1.Right); > g.DrawLine(p, p1, p2); > pb1.Image = bmp; > g.Dispose(); > bmp.Dispose(); > } > > Anybody know what I'm having these problems? > > I appreciate your help btw. > Steve > >
Sorry -- missed the MSDN articles... Here they are: http://msdn.microsoft.com/library/de...us/cscon/html/
vclrfcodedrawinglineonformvisualc.asp http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdrawinggraphicsclassdrawlinestopic.asp http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemDrawingGraphicsClassTopic.asp
Good examples for programming with the graphics object: http://msdn.microsoft.com/library/de...us/cscon/html/
vcsorigraphicsprogrammingexampletopics.asp
Pete Hauge, Visual C# Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
-------------------- I would recommend using the PaintEventArgs object directly instead of creating your own Graphics object and disposing of it... Putting the code directy in the paint method, the code would look like:
private void pb1_Paint(object sender,
System.Windows.Forms.PaintEventArgse) { Pen p = new Pen(Color.AliceBlue, 2); p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; Point p1 = new Point(pb1.Left); Point p2 = new Point(pb1.Right); e.Graphics.DrawLine(p, p1, p2); }
If you want a separate method to draw the line, just pass in the PaintEventArgs, or the Graphics object to the method, "CreateImage".
Some MSDN articles that might help:
Good luck! Pete Hauge, Visual C# Team This posting is provided "AS IS" with no warranties, and confers no
rights.Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
--------------------From: "Steve Long" <No***************@co.clark.wa.us> References: <eX**************@TK2MSFTNGP10.phx.gbl> <#W**************@TK2MSFTNGP10.phx.gbl>Subject: Re: Help drawing a line Date: Mon, 6 Oct 2003 08:41:23 -0700 Lines: 70
Bob, Thanks for your response. That does indeed stop the exception from being thrown but the bitmap still doesn't display. I'm calling the method in the form_paint event. Any idea why I'm not seeing the image?
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:#W**************@TK2MSFTNGP10.phx.gbl... Don't dispose of bmp at the end of your second example.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eX**************@TK2MSFTNGP10.phx.gbl... > Hello, (total GDI newbie) > I'm having trouble drawing just a simple line to display in a picturebox. I > just want a straight, dotdash line. > > I have two methods, one works and one doesn't (it cause an exception
tobe > thrown): > > This one works but it's not the results I want. > private void CreateImage1() > { > Bitmap b = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(b); > g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height)); > pb1.Image = b; > g.Dispose(); > } > > This one cause the exception to be thrown: > private void CreateImage() > { > Bitmap bmp = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(bmp); > Pen p = new Pen(Color.AliceBlue, 2); > p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; > Point p1 = new Point(pb1.Left); > Point p2 = new Point(pb1.Right); > g.DrawLine(p, p1, p2); > pb1.Image = bmp; > g.Dispose(); > bmp.Dispose(); > } > > Anybody know what I'm having these problems? > > I appreciate your help btw. > Steve > >
Peter,
Thanks much for your helpful post. The line is still not being displayed
however. It's like the line is being painted and then it disappears or
something. Any ideas why? Is my system all messed up or something? I pasted
your code directly into the paint event of pb1.
Steve
"Peter Hauge [msft]" <pe********@online.microsoft.com> wrote in message
news:M7**************@cpmsftngxa06.phx.gbl... I would recommend using the PaintEventArgs object directly instead of creating your own Graphics object and disposing of it... Putting the code directy in the paint method, the code would look like:
private void pb1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Pen p = new Pen(Color.AliceBlue, 2); p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; Point p1 = new Point(pb1.Left); Point p2 = new Point(pb1.Right); e.Graphics.DrawLine(p, p1, p2); }
If you want a separate method to draw the line, just pass in the PaintEventArgs, or the Graphics object to the method, "CreateImage".
Some MSDN articles that might help:
Good luck! Pete Hauge, Visual C# Team This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
--------------------From: "Steve Long" <No***************@co.clark.wa.us> References: <eX**************@TK2MSFTNGP10.phx.gbl> <#W**************@TK2MSFTNGP10.phx.gbl>Subject: Re: Help drawing a line Date: Mon, 6 Oct 2003 08:41:23 -0700 Lines: 70
Bob, Thanks for your response. That does indeed stop the exception from being thrown but the bitmap still doesn't display. I'm calling the method in
theform_paint event. Any idea why I'm not seeing the image?
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:#W**************@TK2MSFTNGP10.phx.gbl... Don't dispose of bmp at the end of your second example.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eX**************@TK2MSFTNGP10.phx.gbl... > Hello, (total GDI newbie) > I'm having trouble drawing just a simple line to display in a picturebox. I > just want a straight, dotdash line. > > I have two methods, one works and one doesn't (it cause an exception
tobe > thrown): > > This one works but it's not the results I want. > private void CreateImage1() > { > Bitmap b = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(b); > g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height)); > pb1.Image = b; > g.Dispose(); > } > > This one cause the exception to be thrown: > private void CreateImage() > { > Bitmap bmp = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(bmp); > Pen p = new Pen(Color.AliceBlue, 2); > p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; > Point p1 = new Point(pb1.Left); > Point p2 = new Point(pb1.Right); > g.DrawLine(p, p1, p2); > pb1.Image = bmp; > g.Dispose(); > bmp.Dispose(); > } > > Anybody know what I'm having these problems? > > I appreciate your help btw. > Steve > >
Peter,
I got a bitmap to display in the picturebox using the last link's example
from this list. Thanks again for your help.
Steve
"Peter Hauge [msft]" <pe********@online.microsoft.com> wrote in message
news:$#**************@cpmsftngxa06.phx.gbl... Sorry -- missed the MSDN articles... Here they are: http://msdn.microsoft.com/library/de...us/cscon/html/ vclrfcodedrawinglineonformvisualc.asp http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfsystemdrawinggraphicsclassdrawlinestopic.asp http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfSystemDrawingGraphicsClassTopic.asp
Good examples for programming with the graphics object: http://msdn.microsoft.com/library/de...us/cscon/html/ vcsorigraphicsprogrammingexampletopics.asp
Pete Hauge, Visual C# Team This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
-------------------- I would recommend using the PaintEventArgs object directly instead of creating your own Graphics object and disposing of it... Putting the
codedirecty in the paint method, the code would look like:
private void pb1_Paint(object sender, System.Windows.Forms.PaintEventArgse) { Pen p = new Pen(Color.AliceBlue, 2); p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; Point p1 = new Point(pb1.Left); Point p2 = new Point(pb1.Right); e.Graphics.DrawLine(p, p1, p2); }
If you want a separate method to draw the line, just pass in the PaintEventArgs, or the Graphics object to the method, "CreateImage".
Some MSDN articles that might help:
Good luck! Pete Hauge, Visual C# Team This posting is provided "AS IS" with no warranties, and confers no rights.Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
--------------------From: "Steve Long" <No***************@co.clark.wa.us> References: <eX**************@TK2MSFTNGP10.phx.gbl> <#W**************@TK2MSFTNGP10.phx.gbl>Subject: Re: Help drawing a line Date: Mon, 6 Oct 2003 08:41:23 -0700 Lines: 70
Bob, Thanks for your response. That does indeed stop the exception from being thrown but the bitmap still doesn't display. I'm calling the method in
theform_paint event. Any idea why I'm not seeing the image?
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:#W**************@TK2MSFTNGP10.phx.gbl... Don't dispose of bmp at the end of your second example.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eX**************@TK2MSFTNGP10.phx.gbl... > Hello, (total GDI newbie) > I'm having trouble drawing just a simple line to display in a picturebox. I > just want a straight, dotdash line. > > I have two methods, one works and one doesn't (it cause an exception tobe > thrown): > > This one works but it's not the results I want. > private void CreateImage1() > { > Bitmap b = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(b); > g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width,
b.Height)); > pb1.Image = b; > g.Dispose(); > } > > This one cause the exception to be thrown: > private void CreateImage() > { > Bitmap bmp = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(bmp); > Pen p = new Pen(Color.AliceBlue, 2); > p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; > Point p1 = new Point(pb1.Left); > Point p2 = new Point(pb1.Right); > g.DrawLine(p, p1, p2); > pb1.Image = bmp; > g.Dispose(); > bmp.Dispose(); > } > > Anybody know what I'm having these problems? > > I appreciate your help btw. > Steve > >
Hmm Form Paint is not the best place..
Why are you using a picturebox, is it because you think it's a useful place
to paint an image? PictureBox is just for displaying pictures.
Check this article. http://www.bobpowell.net/accursed_picturebox.htm I know
you're not comitting the cardinal sin but the code is just what you need.
--
Bob Powell [MVP]
C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm
"Steve Long" <No***************@co.clark.wa.us> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl... Bob, Thanks for your response. That does indeed stop the exception from being thrown but the bitmap still doesn't display. I'm calling the method in the form_paint event. Any idea why I'm not seeing the image?
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:#W**************@TK2MSFTNGP10.phx.gbl... Don't dispose of bmp at the end of your second example.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eX**************@TK2MSFTNGP10.phx.gbl... Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox. I just want a straight, dotdash line.
I have two methods, one works and one doesn't (it cause an exception
to be thrown):
This one works but it's not the results I want. private void CreateImage1() { Bitmap b = new Bitmap(100, 100); Graphics g = Graphics.FromImage(b); g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width, b.Height)); pb1.Image = b; g.Dispose(); }
This one cause the exception to be thrown: private void CreateImage() { Bitmap bmp = new Bitmap(100, 100); Graphics g = Graphics.FromImage(bmp); Pen p = new Pen(Color.AliceBlue, 2); p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; Point p1 = new Point(pb1.Left); Point p2 = new Point(pb1.Right); g.DrawLine(p, p1, p2); pb1.Image = bmp; g.Dispose(); bmp.Dispose(); }
Anybody know what I'm having these problems?
I appreciate your help btw. Steve
Bob,
I found your arcticles informative, and, in the process I discovered an
error in my logic. I was misplacing any lines I wanted shown by
miscalculating the x and y values. I found that using the panel control is
fine for creating (at least some of the) graphics that I need to create. I
have a mapping application for which I am creating a legend control that
shows the symbology of each layer for a map. In GIS (geographic information
systems) maps are map up of map layers and each layer has its own symbology.
Thanks for your post
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:eZ**************@TK2MSFTNGP09.phx.gbl... Hmm Form Paint is not the best place..
Why are you using a picturebox, is it because you think it's a useful
place to paint an image? PictureBox is just for displaying pictures.
Check this article. http://www.bobpowell.net/accursed_picturebox.htm I
know you're not comitting the cardinal sin but the code is just what you need.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eP**************@TK2MSFTNGP11.phx.gbl... Bob, Thanks for your response. That does indeed stop the exception from being thrown but the bitmap still doesn't display. I'm calling the method in
the form_paint event. Any idea why I'm not seeing the image?
Steve
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:#W**************@TK2MSFTNGP10.phx.gbl... Don't dispose of bmp at the end of your second example.
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Steve Long" <No***************@co.clark.wa.us> wrote in message news:eX**************@TK2MSFTNGP10.phx.gbl... > Hello, (total GDI newbie) > I'm having trouble drawing just a simple line to display in a picturebox. I > just want a straight, dotdash line. > > I have two methods, one works and one doesn't (it cause an exception to be > thrown): > > This one works but it's not the results I want. > private void CreateImage1() > { > Bitmap b = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(b); > g.DrawEllipse(Pens.Red, new RectangleF(0, 0, b.Width,
b.Height)); > pb1.Image = b; > g.Dispose(); > } > > This one cause the exception to be thrown: > private void CreateImage() > { > Bitmap bmp = new Bitmap(100, 100); > Graphics g = Graphics.FromImage(bmp); > Pen p = new Pen(Color.AliceBlue, 2); > p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; > Point p1 = new Point(pb1.Left); > Point p2 = new Point(pb1.Right); > g.DrawLine(p, p1, p2); > pb1.Image = bmp; > g.Dispose(); > bmp.Dispose(); > } > > Anybody know what I'm having these problems? > > I appreciate your help btw. > Steve > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ComputerSmith |
last post by:
Hi all.
I have programmed VB6 apps before, ones that use dropdown listboxes, text
boxes, etc... normal stuff.
I was asked by a friend to write a "simple" app that I am unsure how to
proceed...
|
by: Mike |
last post by:
Please help this is driving me nuts. I have 2 forms, 1 user class and I am
trying to implement a singleton class. Form 1 should create a user object
and populate some properties in user. Form2...
|
by: Serge Klokov |
last post by:
Hi!
1. Please, help with example "paint on form by mouse"
2. Below is my example, but it clear the line after each Refresh()... how to
fix?
3. How to draw the line in Mouse_Move event?
...
|
by: MFC |
last post by:
Ok, after three C# books, (C# How to Program, Programming in the Key
of C#, and C# Weekend Crash Course) and three weeks, I believe I have
tried everything to make a certain form function...
|
by: Chris Calzaretta |
last post by:
I need to create a form from this web service
http://24.163.239.122/wsprojecttrackerobjects/wsprojecttrackerobjects.asmx
if you call getloginscreen there is a field called screendescription
that...
| |
by: Keith Mills |
last post by:
Hello, please find attached a basic outline of what I am attempting to
accomplish... basically I want to create a number of THREADS (which I can do
fine), but I then need a method for them to be...
|
by: momo |
last post by:
Hello Guys,
I have a bit of a problem, I created a Dll called SecureQueryStringDll.dll
and I had the dll put bin folder of my application first and it did not work
so I then put it in the bin...
|
by: tkempy |
last post by:
okay so i have a CIS class called abstraction and design. i'm completely new to this "java" stuff. I've never seen any of it in my life. our second homework is to create a program that produces a...
|
by: Macias |
last post by:
Hi,
Please help me, how I can make a line drawing on PictureBox similar to
MS paint. I thinking about this: click and hold button, move mouse and
relase button.
I'm trying useing this...
|
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...
|
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,...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |