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 / Design Time / May 2004

Tip: Looking for answers? Try searching our database.

Property Change not recognized

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dennes Oliveira - 04 May 2004 19:45 GMT
Hi !

I created a personalized uitypeeditor with a modal dialog to edit a personalized collection in my component.

The problem is that when I use this dialog to edit the collection it appears that visual studio don't notice that something has changed. Visual Studio doesn't put the "*" mark on the filename indicating that the file changed...

The worse part is that the collection isn't seriallized in this case! The solution is to change some other property, so VS notice the change and serialize everything.

So, is there some command I need to put in code to do something like a "flush", forcing VS to serialize the changes in code ?

Public Class EditorAgregacoes
   Inherits System.Drawing.Design.UITypeEditor

   Public Overloads Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
       Dim f As New frmAgregacoes

       f.esbacesso = context.Instance
       Try
           f.ShowDialog()
       Catch er As Exception
           MsgBox(er.ToString)
       End Try
       Return (f.esbacesso.Agregacoes)
   End Function

   Public Overloads Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
       GetEditStyle = System.Drawing.Design.UITypeEditorEditStyle.Modal
   End Function

   Public Overloads Overrides Function GetPaintValueSupported(ByVal context As System.ComponentModel.ITypeDescriptorContext) As Boolean
       Return (True)
   End Function
End Class
Roland Dick - 06 May 2004 14:25 GMT
> The worse part is that the collection isn't seriallized in this case! The solution is to change some other property, so VS notice the change and serialize everything.

Hi Dennes,

I'm not sure whether this solves your problem, but give
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
a try.

Good luck,

Roland
DRaiko - 07 May 2004 09:27 GMT
Hallo Dennes,

When you return the changed collection, the designer can not
notice any difference. It simply does not know that you have
changed something. The address that you return (the collection
pointer) is the same and the designer can not see what is in
the collection, it does not even realize, that this is
a collection, i suppose.

In the case of scalars (strings, ints, ...) it can see the
difference, and it does: it is enough to return a different value
and the designer notices this (and puts an asteric).

To inform the designer that you have changed something you can call
IComponentChangeService.OnComponentChanging() *before* and
IComponentChangeService.OnComponentChanged() *after* changing the
property. (The std CollectionEditor does the same, i suppose.)
The documentation is not perfect, an important hint is missed
(as i remember): you can pass nulls for all but the first parameter
of the both methods telling that the changes done affect the whole
component and not only one property.

To get IComponentChangeService call GetService() method of
the IServiceProvider argument of EditValue().

Instead of calling these both methods and arranging transactions
you can simply call PropertyDescriptor.SetValue(), that does
the whole stuff with less control from your side.  

The second problem you mention (the collection is not serialized)
is a direct concequence.
If the collection was empty before you call the prop editor and
the designer does not know you have changed the component, it
simply saves time reusing the old serialized code (that
corresponds to an empty collection).

Hope this helps,
Dima.

> Hi !
>
[quoted text clipped - 36 lines]
>
> <Id>+DjS9BSnv0Wp2XGQcZl/RQ==</Id

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.