469,647 Members | 1,863 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

Drawing a dotted line

I tried searching the newsgroups to see how do you draw a dotted line but I
was unable to find an answer, drawing a straight line is very easy but not a
dotted one.

So the question is, how do I draw a dotted line?

Thank you.
Nov 15 '05 #1
6 30214
"Rene" <no****@nospam.nospam> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
I tried searching the newsgroups to see how do you draw a dotted line but I was unable to find an answer, drawing a straight line is very easy but not a dotted one.

So the question is, how do I draw a dotted line?


The way this tends to work in page description languages is the most obvious
trickery - draw a bunch of small short lines in a row.

R.
Nov 15 '05 #2
You can select a line style for a pen that includes standard dot, dot-dash
and so-on or create a custom line style. Lines drawn by pens may also have
end-caps shaped like arrows, diamonds or dots.

Look at System.Drawing.Pen and the DashStyle property which contains a
DashStyle enumeration value.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Rene" <no****@nospam.nospam> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
I tried searching the newsgroups to see how do you draw a dotted line but I was unable to find an answer, drawing a straight line is very easy but not a dotted one.

So the question is, how do I draw a dotted line?

Thank you.

Nov 15 '05 #3
Not bad, if fact not bad at all... but now I need to scale the line so that
the space between the different patterns is bigger, for example I am
currently using the dash-dot style but the dash and dot are so close
together that in a high resolution screen you can barely tell the line is
not a solid line! Is there a way to scale the line spaces or am I going to
have to create a custom style??

Thank you.

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:O%******************@TK2MSFTNGP11.phx.gbl...
You can select a line style for a pen that includes standard dot, dot-dash
and so-on or create a custom line style. Lines drawn by pens may also have
end-caps shaped like arrows, diamonds or dots.

Look at System.Drawing.Pen and the DashStyle property which contains a
DashStyle enumeration value.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Rene" <no****@nospam.nospam> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
I tried searching the newsgroups to see how do you draw a dotted line
but I
was unable to find an answer, drawing a straight line is very easy but
not a
dotted one.

So the question is, how do I draw a dotted line?

Thank you.


Nov 15 '05 #4

Hi Rene,

I think you should do some custom drawing.
For example, you can take Richard's suggestion, do some trickery, draw a
bunch of small short lines combine with some dot.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5
Custom line styles are easy to create and much simpler that trying to
hand-draw a bunch of individual dots and dashes...

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Rene" <no****@nospam.nospam> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
Not bad, if fact not bad at all... but now I need to scale the line so that the space between the different patterns is bigger, for example I am
currently using the dash-dot style but the dash and dot are so close
together that in a high resolution screen you can barely tell the line is
not a solid line! Is there a way to scale the line spaces or am I going to
have to create a custom style??

Thank you.

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:O%******************@TK2MSFTNGP11.phx.gbl...
You can select a line style for a pen that includes standard dot, dot-dash and so-on or create a custom line style. Lines drawn by pens may also have end-caps shaped like arrows, diamonds or dots.

Look at System.Drawing.Pen and the DashStyle property which contains a
DashStyle enumeration value.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Rene" <no****@nospam.nospam> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
I tried searching the newsgroups to see how do you draw a dotted line

but
I
was unable to find an answer, drawing a straight line is very easy but

not
a
dotted one.

So the question is, how do I draw a dotted line?

Thank you.



Nov 15 '05 #6
For example...

Pen dp=new Pen(Brushes.Black,1);

dp.DashPattern=new float[]{10f,3f,3f,3f};

e.Graphics.DrawLine(dp,0,0,100,100);
--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Rene" <no****@nospam.nospam> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
Not bad, if fact not bad at all... but now I need to scale the line so that the space between the different patterns is bigger, for example I am
currently using the dash-dot style but the dash and dot are so close
together that in a high resolution screen you can barely tell the line is
not a solid line! Is there a way to scale the line spaces or am I going to
have to create a custom style??

Thank you.

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:O%******************@TK2MSFTNGP11.phx.gbl...
You can select a line style for a pen that includes standard dot, dot-dash and so-on or create a custom line style. Lines drawn by pens may also have end-caps shaped like arrows, diamonds or dots.

Look at System.Drawing.Pen and the DashStyle property which contains a
DashStyle enumeration value.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Rene" <no****@nospam.nospam> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
I tried searching the newsgroups to see how do you draw a dotted line

but
I
was unable to find an answer, drawing a straight line is very easy but

not
a
dotted one.

So the question is, how do I draw a dotted line?

Thank you.



Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by news-server | last post: by
4 posts views Thread by melanieab | last post: by
1 post views Thread by Carl Gilbert | last post: by
2 posts views Thread by Brian Kendig | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.