PDA

View Full Version : Decimal to Float Problem


PrTester
06-08-2007, 04:57 PM
I'm trying to draw a line with the following code:

graphics.DrawLine(new Pen(Color.Blue), x1, y1,x2, y2);

I define x1,y1,x2,y2 in the variable section as double vars. In the compilation process NT gives me the following messages:

1-The best overloaded method match for 'System.Drawing.Graphics.DrawLine(System.Drawing.P en,float,float,float,float,)
2-Argument '2': cannot convert from 'double' to 'float'
3-Argument '3': cannot convert from 'double' to 'float'
4-Argument '4': cannot convert from 'double' to 'float'
5-Argument '5': cannot convert from 'double' to 'float'

any Ideas how I can make it work?

Regards

NinjaTrader_Ray
06-08-2007, 05:09 PM
Try casting to a float such as:

graphics.DrawLine(new Pen(Color.Blue), (float) x1, (float) y1....)

I believe that should work.

PrTester
06-08-2007, 07:23 PM
Thanks it works.


Try casting to a float such as:

graphics.DrawLine(new Pen(Color.Blue), (float) x1, (float) y1....)

I believe that should work.

NinjaTrader_Ray
06-09-2007, 09:35 AM
Excellent, glad to have been of help.