.NETGURU
Best way to draw a filled rectangle with border
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-drawing' list.


xico
Hi,

What's the best way to draw a filled rectangle with border?

Thanks,

- xico -

Reply to this message...
 
    
Jason Sellers
Assuming you have a Rectangle (myRect) and a Graphics object (g), how
about...

    g.FillRectangle(SystemBrushes.Desktop, myRect); //Draws the
"fill"
    g.DrawRectangle(SystemPens.ControlDark, myRect); //Draws the
"border"

jason

-----Original Message-----
From: xico [mailto:Click here to reveal e-mail address]=20
Sent: Monday, November 26, 2001 7:09 AM
To: ngfx-drawing
Subject: [ngfx-drawing] Best way to draw a filled rectangle with border

Hi,

What's the best way to draw a filled rectangle with border?

Thanks,

- xico -

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngbeta.asp =3D JOIN/QUIT=20
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
    
xico
Folks,

It's just me or GDI+ isn't that good.
Ok, you can do gradient filling with easy, but to draw a simple Filled
rectangle with border you have to call two methods...

In old gdi, you select a pen and a brush and call Rectangle.

But what drives me crazy is the Rectangle class. Maybe I didn't read the
docs properly, but this kind of thing that I was used to do with MFC is not
that simple anymore:

CRect rc = rcSrc;
rc.top += 20;

to do it in GDI+, according to my way:

Rectangle rc = new Rectangle(x, y, width, height);
rc.X += 20;
rc.Height -= 20;

This is awfull...

Cheers,
- xico -

----- Original Message -----
From: "Jason Sellers" <Click here to reveal e-mail address>
To: "ngfx-drawing" <Click here to reveal e-mail address>
Sent: Monday, November 26, 2001 5:50 PM
Subject: [ngfx-drawing] RE: Best way to draw a filled rectangle with border

Assuming you have a Rectangle (myRect) and a Graphics object (g), how
about...

g.FillRectangle(SystemBrushes.Desktop, myRect); //Draws the
"fill"
g.DrawRectangle(SystemPens.ControlDark, myRect); //Draws the
"border"

jason

Reply to this message...
 
 
System.Drawing.Rectangle
System.Drawing.SystemBrushes
System.Drawing.SystemPens




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification