protected System.Windows.Forms.Button MyButton; change to public System.Windows.Forms.Button MyButton;And pow, it works. Here I will give you a full example of a form.
using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; namespace MyForm { public class MyForm : System.Windows.Forms.Form { public Button OKButton; public Button CancelButton; private System.ComponentModel.IContainer components = null; public MyForm() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Designer generated code private void InitializeComponent() { this.OKButton = new Button(); this.cmdCancel = Button(); this.SuspendLayout(); // // OKButton // this.OKButton.DialogResult = System.Windows.Forms.DialogResult.OK; this.OKButton.Location = new System.Drawing.Point(136, 232); this.OKButton.Name = "OKButton"; this.OKButton.Rule = ""; this.OKButton.TabIndex = 0; this.OKButton.Text = "OK"; // // CancelButton // this.CancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.CancelButton.Location = new System.Drawing.Point(216, 232); this.CancelButton.Name = "CancelButton"; this.CancelButton.Rule = ""; this.CancelButton.TabIndex = 1; this.CancelButton.Text = "Cancel"; // // MyDialogForm // this.AcceptButton = this.cmdOK; this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.CancelButton = this.cmdCancel; this.ClientSize = new System.Drawing.Size(402, 279); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.CancelButton, this.OKButton}); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "MyForm"; this.ResumeLayout(false); } #endregion } }Ok, I hope that works. I can't really help you anymore then that.