Has anyone experiance or a running example how to use within VS C# the NetLink.UI pictureBox to plot graphics, especially using the pictureBox - "MathCommand"

I use the code example below which throw a System.FormatException - wrong input character format

IKernelLink mathKernelLink = MathLinkFactory.CreateKernelLink();
MathKernel mathKernel = new MathKernel();

pictureBox2.Link = mathKernelLink;
mathKernel.GraphicsHeight = pictureBox2.Height;
mathKernel.GraphicsWidth = pictureBox2.Width;

pictureBox2.PictureType = "Automatic";

try { pictureBox2.MathCommand = "Plot[x, {x,0,1}]";} 
catch ( FormatException e )
{ Console.WriteLine(e); }

if (mathKernel.Graphics.Length > 0)
pictureBox2.Image = mathKernel.Graphics[0];
| improve this question | | | | |
  • $\begingroup$ From the documentation: "To have the MathPictureBox display the result of a computation, set the MathCommand property to a string of Mathematica code (for example, Plot[x, {x,0,1}])." Did it not work as described? Some other common problems are described here. $\endgroup$ – Oleksandr R. Aug 30 '15 at 23:21
  • $\begingroup$ Thanks Oleksandr, I've just added a part of my code example which gives a FormatException ? $\endgroup$ – wezi Aug 31 '15 at 7:13
  • $\begingroup$ Ok, it works in case if "pictureBox2.Link = mathKernel.Link" are set. $\endgroup$ – wezi Oct 2 '15 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.