all groups > dotnet drawing api > may 2005 >
You're in the

dotnet drawing api

group:

Drawing a line with a bevel ot sunken effect


Drawing a line with a bevel ot sunken effect Craig
5/31/2005 6:26:03 PM
dotnet drawing api:
Hi

I'm trying to draw a 1px horizontal line that has a sunken/bevel effect.
Same style as the seperator lines displayed in a file property dialog (open
Windows Explorer, right click a file, select Properties)

Fairly new to WinForms, so any suggestions are appreciated.

Re: Drawing a line with a bevel ot sunken effect Bob Powell [MVP]
6/1/2005 12:00:00 AM
That's impossible to do with a 1 pixel line. The minimum is two pixels.

You can do your own by drawing rectangles offset from one another by a pixel
or use the ControlPaint class which has some border drawing routines.

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

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

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

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





[quoted text, click to view]

Re: Drawing a line with a bevel ot sunken effect Craig
6/1/2005 6:41:02 AM
Hi Bob
Thanks for the reply, I ended taking the 2 line approach; however I didn't
know about ContralPaint. What would you suggest?

Thanks again.
Craig

[quoted text, click to view]
Re: Drawing a line with a bevel ot sunken effect Bob Powell [MVP]
6/1/2005 8:38:00 PM
ControlPaint is great for vanilla effects. If you want something a bit more
specific then roll-your-own graphics is great.

The idea is to show a highlight to the upper-left and a shadow to the
lower-right. These effects can be more or less complex.

For example..

protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.White,new Rectangle(10,10,300,200));
e.Graphics.DrawRectangle(Pens.DarkGray, new Rectangle(11,11,300,200));
}

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

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

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

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





[quoted text, click to view]

AddThis Social Bookmark Button