Trying out OxyPlot, installed and referenced packages. Copying and pasting the example from here http://docs.oxyplot.org/en/latest/getting-started/hello-windows-forms.html but it doesn't recognize plot1
from the last line. I am guessing because the control isn't added to the form. How do I add it? I don't see it in the toolbox, and I tried adding the control to the toolbox and can't find it anywhere. Thanks.
I just had this very issue myself. I tried adding the Reference (right click References in the Solution Explorer, then browse for the "OxyPlot.dll" and "OxyPlot.WindowsForms.dll" files.) At first it didn't work; kept getting an error.
I noticed there were two versions of the "Oxyplot.dll; a net40 and a net45. I was originally using the net45 version. I copied the net40 version to the same place as the "OxyPlot.WindowsForms.dll", added the Reference, went to the toolbox, added a new tab, then added the reference to the tab (right click tab -> Choose Items, then search for Oxyplot).
I now have Pointer and PlotView in the toolbox. I'm using VS2017 Community with a Forms app. The manual version above worked for me too.
You said "I tried adding the control to the toolbox and can't find it anywhere.". It may not have found your installation of Oxyplot.WindowsForms. While in your visual studio project, after you right click on the Toolbox area, click on '.Net Framework Components' and then click 'Browse' and locate the "OxyPlot.WindowsForms.dll". If you installed it into your project it should be in one of the packages subfolders like packages\\lib folder.
You may add the Plot Control Manually by appending these lines in the Form designer under the initialize component method.
private void InitializeComponent()
{
this.plot1 = new OxyPlot.WindowsForms.PlotView();
this.SuspendLayout();
//
// plot1
//
this.plot1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.plot1.Location = new System.Drawing.Point(0, 0);
this.plot1.Name = "plot1";
this.plot1.PanCursor = System.Windows.Forms.Cursors.Hand;
this.plot1.Size = new System.Drawing.Size(500,500);
this.plot1.TabIndex = 0;
this.plot1.Text = "plot1";
this.plot1.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
this.plot1.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
this.plot1.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
this.Controls.Add(this.plot1);
//
// other comtrols
//
}
private OxyPlot.WindowsForms.PlotView plot1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With