Forum  Commercial Foru...  Commercial Foru...  Intercepting property changes at design time
Previous Previous
 
Next Next
New Post 1/20/2012 7:33 AM
  infotrac
82 posts
No Ranking


Intercepting property changes at design time 

Hi,

Is there a way to intercept the changes made to a control's property inside Properties window at design time? For example, some enters some text into Properties window for a specific property of the control and I parse the entered text and assign the result to another property etc.

Thanks,

Alex

 
New Post 1/20/2012 8:11 AM
  infotrac
82 posts
No Ranking


Re: Intercepting property changes at design time 

Sorry, the question is rather, if there is a way to update the values inside the Properties window without switching views/closing the form etc. Because now, when I am changing one property value inside Properties window, its setter changes the value in other property accordingly, but it won't get displayed in Properties window until I have switched between Form Design and Code views. Is there a way to refresh Properties window to display current control properties values?

 
New Post 1/20/2012 12:10 PM
  palli
14313 posts
1st Level Poster




Re: Intercepting property changes at design time 
Modified By palli  on 1/20/2012 5:21:08 PM)

Hi Alex,

If I understand you correctly, you would have a custom textbox with something like this:

        private string _SecondaryText;
        public string SecondaryText
        {
            get { return _SecondaryText; }
            set
            {
                if (this.Text != value)
                    this.Text = value;
                _SecondaryText = value;
            }
        }
And you would want the update on the Text property update right away on the propertygrid and within the designer.

I will need to consult with the developers on this one, as I am not much familiar with the designer yet.

I will let you know as soon as I have had a response from them on this one.

P.S. For your information, I'm also pushing for a reply on your other design-time related thread from here.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 1/22/2012 8:34 AM
  palli
14313 posts
1st Level Poster




Re: Intercepting property changes at design time 

Hi Alex,

As it turns out, having properties update inside the designer's PropertyGrid is one thing, and updating it within the designer UI at the same time is another.

For updating the PropertyGrid contents, you can simply add RefreshProperty attribute to your custom property. Using the same sample for the TextBox as I used before, the property declaration can be:

        [RefreshProperties(RefreshProperties.Repaint)]
        public string SecondaryText
        {
            get { return _SecondaryText; }
            set
            {
                if (this.Text != value)
                    this.Text = value;
                _SecondaryText = value;
            }
        }
 

This would get the Text property updated inside the designer's propertygid.

Updating it within the designer UI area will require that you create a custom controller and then set the DesignTimeController of your class to be your custom controller. The controllers mechanism is all part of our public code, so you should take a look there to see what options you have for customizations. Just remember that the controller's role is a kind of bridging the gap between the WebForm control that is the output of your designer, and the WinForms control used within the designer UI while designing. You will soon see that every controller has a SourceObject (the webcontrol) and a TargetObject (the wincontrol) and it's bridging between those two.

Again, building on the SecondaryText property sample, I created a demo application for you here, that implements a custom controller that, along with the the RefreshProperties attribute setting, make sure that when you update the new custom SecondaryText property within the propertygrid, it will update the Text property within the propertygrid (because of the attirbute setting) and then update the Text within the TextBox on your form inside the design UI, fully updating all the "triggered" updates both in propertygrid and designer.

Hope this helps,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 1/24/2012 11:27 AM
  infotrac
82 posts
No Ranking


Re: Intercepting property changes at design time 

Hi Palli,

I have added [RefreshProperties(RefreshProperties.Repaint)] above the property and after I change its value it seems to try to refresh the Properties window. But now the problem is, that the Properties window goes blank in the process of refreshment and only displays data again after I click on the control again in the designer. Is this how it's supposed to behave?

Thanks,

Alex

 
Previous Previous
 
Next Next
  Forum  Commercial Foru...  Commercial Foru...  Intercepting property changes at design time
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS