G
Guest
Hi,
I have this custom control (derived from a TextBox) with a property. I find it bothersome to go through the (long) property list to set a simple, (for me most important) property in the property list.
So, I created a custom designer, and when I right-click the control I get a popup menu, where I can select my value. Works fine.
But, if I use the popupmenu_click handle to set the property, it doesn't get serialized on saving. Instead, the value saved is still from the property list, so that's the old value....
Now, how do I get the property list to update and reflect the new value?
Do I have to create an editor, and capture some MyPropertyChanged event, and then set it in the editor?
Currently I have the code like below.
class MyTextBox : TextBox
{
private string myProperty
public string MyProperty
{ get { return this.myProperty; } set { this.myProperty = value; }
.....
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if(this.DesignMode)
{
ContextMenu contextMenu = new ContextMenu()
...
contextMenu.Show(this, new Point(e.X, e.Y));
}
}
public void MenuItem_Click(object sender, System.EventArgs e)
{
this.MyProperty = (e as MenuItem).Text
}
I have this custom control (derived from a TextBox) with a property. I find it bothersome to go through the (long) property list to set a simple, (for me most important) property in the property list.
So, I created a custom designer, and when I right-click the control I get a popup menu, where I can select my value. Works fine.
But, if I use the popupmenu_click handle to set the property, it doesn't get serialized on saving. Instead, the value saved is still from the property list, so that's the old value....
Now, how do I get the property list to update and reflect the new value?
Do I have to create an editor, and capture some MyPropertyChanged event, and then set it in the editor?
Currently I have the code like below.
class MyTextBox : TextBox
{
private string myProperty
public string MyProperty
{ get { return this.myProperty; } set { this.myProperty = value; }
.....
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if(this.DesignMode)
{
ContextMenu contextMenu = new ContextMenu()
...
contextMenu.Show(this, new Point(e.X, e.Y));
}
}
public void MenuItem_Click(object sender, System.EventArgs e)
{
this.MyProperty = (e as MenuItem).Text
}