In fact, in the limited feature desired by you, I tried the method being used by you, and good news for you, it works! The only change I made in your code (as shown above) is that I have used "public myVarEnum MyProperty" instead of "public myVar MyProperty" as used in your code (which appears to be a typing mistake), while defining the property. In the sample small project prepared by me, the values "Mango" and "Peach" also persist if set at design time from the Property window from the dropdown. If you wish, I can separately send you the sample project files. Otherwise, I am including the source code of the MyButton.cs file (the inherited control) and the Form1.cs hereinbelow for your information:
//MyTextBox.cs file
using System;
namespace TestControl2
{
/// /// Summary description for MyTextBox.
///
public class MyTextBox : System.Windows.Forms.TextBox
{
public enum myVarEnum {Apple,Mango,Peach};
protected myVarEnum myvar1;
public myVarEnum MyProperty
{
get { return myvar1; }
set { myvar1 = value; }
}
public MyTextBox()
{
//
// TODO: Add constructor logic here
//
}
}
}
//Form1.cs file
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace TestControl2
{
/// /// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private TestControl2.MyTextBox myTextBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
/// /// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// /// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// /// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.myTextBox1 = new TestControl2.MyText