adding GLcontrol to visual studio toolbox

niceman picture niceman · Nov 19, 2014 · Viewed 7.1k times · Source

maybe the question is simple but I'm using OpenTK with WinForms , the problem is I can't find GLcontrol in the toolbox , so I added it manually in Form1.Designer.cs , this is the code #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        glcontrol1 = new OpenTK.GLControl();
        this.SuspendLayout();
        // 
        // glControl1
        // 

        // 
        // Form1
        // 
        this.Controls.Add(glcontrol1);
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(584, 561);     
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.ResumeLayout(false);

    }

    #endregion
    OpenTK.GLControl glcontrol1;

the problem is when I open Form1 in design mode , It shows these messages "could not load type OpenTK.ToolkitOptions from assembly ..." "the variable glcontrol1 is either undeclared or not assigned " I'd like a way to add GLcontrol to toolbox , anyone knows how ?

Answer

The Fiddler picture The Fiddler · Nov 20, 2014

Double check your project references, you need both OpenTK.dll and OpenTK.GLControl.dll.

Adding GLControl to the WinForms toolbox is covered under "Building a Windows.Forms + GLControl based application" in the documentation.

To begin with, create a Form on which you will place your GLControl. Right click in some empty space of the Toolbox, pick "Choose Items..." and browse for OpenTK.GLControl.dll. Make sure you can find the "GLControl" listed in the ".NET Framework Components", as in the image below.

Adding GLControl to the Toolbox

Then you can add the GLControl to your form as any .NET control. A GLControl named glControl1 will be added to your Form.