Home All Groups Group Topic Archive Search About

PropertyChanged event with VB.NET (.NET 1.1)

Author
19 Feb 2006 10:37 PM
Mark
Hi.

I searched for hours now but can't find how to get the following to work:

A usercontrol with two properties (A and B).
If A is changed in the designer, B should be changed as well.
This works but the change in B is not instantly reflected in the
designer, it's only shown if you click on B and then the new value is shown.

In VB6 this works by calling PropertyChanged "B".
In VB.NET 2.0 this also works using some INotifyPropertyChanged thing.
But how does it work with VB.NET 1.1?

I even wrote a VB6 app (where everything worked) and then used the
upgrade manager from VB.NET to convert the project. It renamed the
events but the changes are not reflected in the designer as it did in VB6.

The only thing remotely helpful I found is this page
http://www.interact-sw.co.uk/iangblog/2004/10/23/propertychange
which seems a bit too complicated for such an easy(?) problem.

Public Class UC
     Inherits System.Windows.Forms.UserControl

     Private m_A as integer
     Private m_B as integer

     Public Property A As Integer
         Get
             Return m_A
         End Get
         Set(ByVal Value As Integer)
             m_A = Value
             m_B = m_A
         End Set
     End Property

     Public Property B As Integer
         Get
             Return m_B
         End Get
         Set(ByVal Value As Integer)
             m_B = Value
         End Set
     End Property

end class

Any help would be greatly appreciated
Mark

Author
20 Feb 2006 12:08 AM
Rocky
Use the RefreshProperties attribute
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemComponentModelRefreshPropertiesClassTopic.asp

Show quoteHide quote
"Mark" <n***@eggenstein.net> wrote in message
news:eYuvRUaNGHA.3936@TK2MSFTNGP10.phx.gbl...
> Hi.
>
> I searched for hours now but can't find how to get the following to work:
>
> A usercontrol with two properties (A and B).
> If A is changed in the designer, B should be changed as well.
> This works but the change in B is not instantly reflected in the designer,
> it's only shown if you click on B and then the new value is shown.
>
> In VB6 this works by calling PropertyChanged "B".
> In VB.NET 2.0 this also works using some INotifyPropertyChanged thing.
> But how does it work with VB.NET 1.1?
>
> I even wrote a VB6 app (where everything worked) and then used the upgrade
> manager from VB.NET to convert the project. It renamed the events but the
> changes are not reflected in the designer as it did in VB6.
>
> The only thing remotely helpful I found is this page
> http://www.interact-sw.co.uk/iangblog/2004/10/23/propertychange
> which seems a bit too complicated for such an easy(?) problem.
>
> Public Class UC
>     Inherits System.Windows.Forms.UserControl
>
>     Private m_A as integer
>     Private m_B as integer
>
>     Public Property A As Integer
>         Get
>             Return m_A
>         End Get
>         Set(ByVal Value As Integer)
>             m_A = Value
>             m_B = m_A
>         End Set
>     End Property
>
>     Public Property B As Integer
>         Get
>             Return m_B
>         End Get
>         Set(ByVal Value As Integer)
>             m_B = Value
>         End Set
>     End Property
>
> end class
>
> Any help would be greatly appreciated
> Mark
Author
21 Feb 2006 1:10 AM
Dennis
Do you have an example using the RefreshProperties Attribute?  Sounds like
what I'm looking for in my usercontrol.  Thanks for any help.
--
Dennis in Houston


Show quoteHide quote
"Rocky" wrote:

> Use the RefreshProperties attribute
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemComponentModelRefreshPropertiesClassTopic.asp
>
> "Mark" <n***@eggenstein.net> wrote in message
> news:eYuvRUaNGHA.3936@TK2MSFTNGP10.phx.gbl...
> > Hi.
> >
> > I searched for hours now but can't find how to get the following to work:
> >
> > A usercontrol with two properties (A and B).
> > If A is changed in the designer, B should be changed as well.
> > This works but the change in B is not instantly reflected in the designer,
> > it's only shown if you click on B and then the new value is shown.
> >
> > In VB6 this works by calling PropertyChanged "B".
> > In VB.NET 2.0 this also works using some INotifyPropertyChanged thing.
> > But how does it work with VB.NET 1.1?
> >
> > I even wrote a VB6 app (where everything worked) and then used the upgrade
> > manager from VB.NET to convert the project. It renamed the events but the
> > changes are not reflected in the designer as it did in VB6.
> >
> > The only thing remotely helpful I found is this page
> > http://www.interact-sw.co.uk/iangblog/2004/10/23/propertychange
> > which seems a bit too complicated for such an easy(?) problem.
> >
> > Public Class UC
> >     Inherits System.Windows.Forms.UserControl
> >
> >     Private m_A as integer
> >     Private m_B as integer
> >
> >     Public Property A As Integer
> >         Get
> >             Return m_A
> >         End Get
> >         Set(ByVal Value As Integer)
> >             m_A = Value
> >             m_B = m_A
> >         End Set
> >     End Property
> >
> >     Public Property B As Integer
> >         Get
> >             Return m_B
> >         End Get
> >         Set(ByVal Value As Integer)
> >             m_B = Value
> >         End Set
> >     End Property
> >
> > end class
> >
> > Any help would be greatly appreciated
> > Mark
>
>
>
Author
21 Feb 2006 2:25 AM
Rocky
Imports System.ComponentModel

<RefreshProperties(RefreshProperties.All)> _
Public Property Enabled() As Boolean
        Get
            Return isEnabled
        End Get
        Set(ByVal Value As Boolean)
            isEnabled = Value
        End Set
End Property



Show quoteHide quote
"Dennis" <Den***@discussions.microsoft.com> wrote in message
news:7838F741-0893-4177-A24F-C16F93B5CEE2@microsoft.com...
> Do you have an example using the RefreshProperties Attribute?  Sounds like
> what I'm looking for in my usercontrol.  Thanks for any help.
> --
> Dennis in Houston
>
>
> "Rocky" wrote:
>
>> Use the RefreshProperties attribute
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemComponentModelRefreshPropertiesClassTopic.asp
>>
>> "Mark" <n***@eggenstein.net> wrote in message
>> news:eYuvRUaNGHA.3936@TK2MSFTNGP10.phx.gbl...
>> > Hi.
>> >
>> > I searched for hours now but can't find how to get the following to
>> > work:
>> >
>> > A usercontrol with two properties (A and B).
>> > If A is changed in the designer, B should be changed as well.
>> > This works but the change in B is not instantly reflected in the
>> > designer,
>> > it's only shown if you click on B and then the new value is shown.
>> >
>> > In VB6 this works by calling PropertyChanged "B".
>> > In VB.NET 2.0 this also works using some INotifyPropertyChanged thing.
>> > But how does it work with VB.NET 1.1?
>> >
>> > I even wrote a VB6 app (where everything worked) and then used the
>> > upgrade
>> > manager from VB.NET to convert the project. It renamed the events but
>> > the
>> > changes are not reflected in the designer as it did in VB6.
>> >
>> > The only thing remotely helpful I found is this page
>> > http://www.interact-sw.co.uk/iangblog/2004/10/23/propertychange
>> > which seems a bit too complicated for such an easy(?) problem.
>> >
>> > Public Class UC
>> >     Inherits System.Windows.Forms.UserControl
>> >
>> >     Private m_A as integer
>> >     Private m_B as integer
>> >
>> >     Public Property A As Integer
>> >         Get
>> >             Return m_A
>> >         End Get
>> >         Set(ByVal Value As Integer)
>> >             m_A = Value
>> >             m_B = m_A
>> >         End Set
>> >     End Property
>> >
>> >     Public Property B As Integer
>> >         Get
>> >             Return m_B
>> >         End Get
>> >         Set(ByVal Value As Integer)
>> >             m_B = Value
>> >         End Set
>> >     End Property
>> >
>> > end class
>> >
>> > Any help would be greatly appreciated
>> > Mark
>>
>>
>>
Author
21 Feb 2006 10:53 AM
Mark
Rocky wrote:
> <RefreshProperties(RefreshProperties.All)> _
>  Public Property Enabled() As Boolean

I tried the RefreshProperties in front of the class definition and it
still did not work. Thanks for giving this easy example, that gave me
the important hint to use it directly with property.

Mark
Author
22 Feb 2006 12:07 AM
Dennis
Grrrrrrrrreat..thanks for the code..I've put it in my examples.
--
Dennis in Houston


Show quoteHide quote
"Rocky" wrote:

> Imports System.ComponentModel
>
> <RefreshProperties(RefreshProperties.All)> _
>  Public Property Enabled() As Boolean
>         Get
>             Return isEnabled
>         End Get
>         Set(ByVal Value As Boolean)
>             isEnabled = Value
>         End Set
>  End Property
>
>
>
> "Dennis" <Den***@discussions.microsoft.com> wrote in message
> news:7838F741-0893-4177-A24F-C16F93B5CEE2@microsoft.com...
> > Do you have an example using the RefreshProperties Attribute?  Sounds like
> > what I'm looking for in my usercontrol.  Thanks for any help.
> > --
> > Dennis in Houston
> >
> >
> > "Rocky" wrote:
> >
> >> Use the RefreshProperties attribute
> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemComponentModelRefreshPropertiesClassTopic.asp
> >>
> >> "Mark" <n***@eggenstein.net> wrote in message
> >> news:eYuvRUaNGHA.3936@TK2MSFTNGP10.phx.gbl...
> >> > Hi.
> >> >
> >> > I searched for hours now but can't find how to get the following to
> >> > work:
> >> >
> >> > A usercontrol with two properties (A and B).
> >> > If A is changed in the designer, B should be changed as well.
> >> > This works but the change in B is not instantly reflected in the
> >> > designer,
> >> > it's only shown if you click on B and then the new value is shown.
> >> >
> >> > In VB6 this works by calling PropertyChanged "B".
> >> > In VB.NET 2.0 this also works using some INotifyPropertyChanged thing.
> >> > But how does it work with VB.NET 1.1?
> >> >
> >> > I even wrote a VB6 app (where everything worked) and then used the
> >> > upgrade
> >> > manager from VB.NET to convert the project. It renamed the events but
> >> > the
> >> > changes are not reflected in the designer as it did in VB6.
> >> >
> >> > The only thing remotely helpful I found is this page
> >> > http://www.interact-sw.co.uk/iangblog/2004/10/23/propertychange
> >> > which seems a bit too complicated for such an easy(?) problem.
> >> >
> >> > Public Class UC
> >> >     Inherits System.Windows.Forms.UserControl
> >> >
> >> >     Private m_A as integer
> >> >     Private m_B as integer
> >> >
> >> >     Public Property A As Integer
> >> >         Get
> >> >             Return m_A
> >> >         End Get
> >> >         Set(ByVal Value As Integer)
> >> >             m_A = Value
> >> >             m_B = m_A
> >> >         End Set
> >> >     End Property
> >> >
> >> >     Public Property B As Integer
> >> >         Get
> >> >             Return m_B
> >> >         End Get
> >> >         Set(ByVal Value As Integer)
> >> >             m_B = Value
> >> >         End Set
> >> >     End Property
> >> >
> >> > end class
> >> >
> >> > Any help would be greatly appreciated
> >> > Mark
> >>
> >>
> >>
>
>
>