Page 1 of 1

using datetime with colorline tool

Posted: Tue Sep 11, 2007 9:33 pm
by 9640386
Hello,

I'm trying to draw a colored line at a specific point on the x-axis of my chart using the colorline tool. The x-axis is date and time, which is giving me problems. I think this should work..


Line 82: colorLine1.Axis = WebChart1.Chart.Axes.Bottom
Line 83: colorLine1.Pen.Color = Drawing.Color.Yellow
Line 84: colorLine1.Value = "8/21/2007 11:14:00 AM"
Line 85:

But I get the following error..

Exception Details: System.FormatException: Input string was not in a correct format.


Can you tell me what I'm doing wrong?

cheers, Paul

Posted: Wed Sep 12, 2007 10:05 am
by narcis
Hi LordWhorfin,

You should use something like this:

Code: Select all

			colorLine1.Value = DateTime.Parse("8/21/2007 11:14:00 AM");

Posted: Wed Sep 12, 2007 2:12 pm
by 9640386
narcis wrote:Hi LordWhorfin,

You should use something like this:

Code: Select all

			colorLine1.Value = DateTime.Parse("8/21/2007 11:14:00 AM");
That generates an error..

Conversion from 'Date' to 'Double' requires calling the 'Date.YoOADate' method.

Posted: Wed Sep 12, 2007 2:23 pm
by narcis
HI LordWhorfin,

Sorry, what about this then?

Code: Select all

         colorLine1.Value = DateTime.Parse("8/21/2007 11:14:00 AM").ToOADate();

Posted: Wed Sep 12, 2007 4:29 pm
by 9640386
narcis wrote:HI LordWhorfin,

Sorry, what about this then?

Code: Select all

         colorLine1.Value = DateTime.Parse("8/21/2007 11:14:00 AM").ToOADate();
That did it, thank you. Paul