Page 1 of 1

Passing a Color reference to a ChartPen

Posted: Fri May 04, 2007 4:51 pm
by 9643227
How do I pass a Color reference to a ChartPen so that when the Color property of the ChartPen changes, my Color reference changes accordingly? Thank you.

Jeff

Posted: Mon May 07, 2007 10:38 am
by narcis
Hi Jeff,

You can try using a variable of System.Drawing.Color type:

Code: Select all

					System.Drawing.Color MyColor = Color.FromArgb(255, 0, 0);
					line1.LinePen.Color = MyColor;

Posted: Tue May 08, 2007 6:38 pm
by 9643227
I am afraid the code you provide does not work: if one changes the Color of LinePen, MyColor won't get the change.

Anyway, I solved this by adding a public function in the ChartPen class:

Code: Select all

        public void SetColorref(ref Color color)
        {
            color = this.Color;
        }

With this function , the following code works:

Code: Select all

Color MyColor = Color.FromArgb(255, 0, 0);
line1.LinePen.Color.SetColorref(ref MyColor);
Jeff