3
votes

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 ?

1
this is the call stack in case needed : at OpenTK.GLControl..ctor(GraphicsMode mode, Int32 major, Int32 minor, GraphicsContextFlags flags) at OpenTK.GLControl..ctor()niceman

1 Answers

3
votes

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.