How do I pass along variable in a custom control?

I've created a custom control in C# in VSE, and it appears on the list on the left. But I want to pass along a reference to my main form, and I'm currently doing so in the constructor. And then I've manually edited, the VSE Designer generated code to pass along the form itself. But hereafter when i try to with the designview VSE shows an errormessage. Have i done this the wrong way?

class canvas : Control
 {

     public canvas(Form1 theForm)
     {

     }
 }

And then in the designer generated code:

this.canvas2 = new panel2.canvas(this);

Answers


you could just use a public property.

public Form1 mainForm { get; set; }

You can then pass it in as a parameter on your canvas object.

<canvas mainForm='<%= this %>'></canvas>

Or from code:

this.canvas2.mainForm = this;

Need Your Help

jQuery serializeArray + ajax.post IE (only) occasionally does not pass form elements to ashx Handler

c# jquery ajax ashx web-farm

My .ashx Handler called from a jQuery AJAX post occasionally does not receive form elements in the HttpContext.Request.

how to maintain user preferences across multiple domains in PHP

php cookies cross-domain expressionengine redirectwithcookies

i am developing a multilingual site in expression engine. and i am using different domains for different languages versions of site eg: www.site.en, www.site.jp, etc.

How to update particular record using update query in SQL Server with vb.net?

asp.net vb.net

I have the query to retrieve selected record in textbox ./..