Click to See Complete Forum and Search --> : Help!! Problem with System.Drawing... Rectangles always upside down


obsessedandre
February 17th, 2002, 01:59 AM
Hi everyone.
I am making a bar chart using System.Drawing. I've figured out how to
do it, but with one problem. The rectangles that are being drawn for
the bars in the chart are always upside down. I don't know why. When I
set the y property of the rectangle, I figured that would be the base
of the rectangle and the height of my rectangle would make it higher
from there. But instead y acts as the top of my rectangle and the rest
is underneath it. So the effect is that my bar charts are upside
down... sagging down as apposed to going up.
Here is the code I am using to create my bar chart rectangle:

//Draw rectangle to make a bar in the chart
objGraphics.DrawRectangle(new Pen(Color.Blue, 2), xInt, yInt,
barWidth, barHeight);
//Create gradient brush
LinearGradientBrush lBrush = new LinearGradientBrush(rect,
Color.Yellow, Color.Red, LinearGradientMode.Vertical);
//Fill rectangle with gradient
objGraphics.FillRectangle(lBrush, rect);

I noticed a few other articles where people said they had problems
with System.Drawing outputting upside down, but there were no answers
that applied to what I am doing, so any help with this is very greatly
appreciated.

Thanks.

obsessedandre
February 17th, 2002, 01:59 AM
Hi everyone.
I am making a bar chart using System.Drawing. I've figured out how to
do it, but with one problem. The rectangles that are being drawn for
the bars in the chart are always upside down. I don't know why. When I
set the y property of the rectangle, I figured that would be the base
of the rectangle and the height of my rectangle would make it higher
from there. But instead y acts as the top of my rectangle and the rest
is underneath it. So the effect is that my bar charts are upside
down... sagging down as apposed to going up.
Here is the code I am using to create my bar chart rectangle:

//Draw rectangle to make a bar in the chart
objGraphics.DrawRectangle(new Pen(Color.Blue, 2), xInt, yInt,
barWidth, barHeight);
//Create gradient brush
LinearGradientBrush lBrush = new LinearGradientBrush(rect,
Color.Yellow, Color.Red, LinearGradientMode.Vertical);
//Fill rectangle with gradient
objGraphics.FillRectangle(lBrush, rect);

I noticed a few other articles where people said they had problems
with System.Drawing outputting upside down, but there were no answers
that applied to what I am doing, so any help with this is very greatly
appreciated.

Thanks.