Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2004

Tip: Looking for answers? Try searching our database.

Designtime Property Setting outside propertylist

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ronald - 30 Jul 2004 11:15 GMT
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
 }
Ronald - 30 Jul 2004 12:39 GMT
FYI: I solved it, thanks to this link:

http://www.windowsforms.com/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=17562

The designer now responses to a MyPropertyChanged event, and uses this code:

 IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService));

 c.OnComponentChanging(this.myControl, null);
 this.myControl.MyProperty = e.MyProperty;
 c.OnComponentChanged(this.myControl, null, null, null);

(this.myControl is set in the constructor of the designer)

Thanks all
Ronald

> Hi,
>
[quoted text clipped - 32 lines]
>        this.MyProperty = (e as MenuItem).Text
>   }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.