On May 13, 2006, at 12:07 PM, Tony Cerrato wrote:
I am feeling like an idiot. What syntax do I use inside of a Get
and Set method of a Computed Property?
If I wish to have a computed property (e.g., of type integer), that
does nothing more than mimic a "normal" property, what code do I
put inside the Get and Set methods?
A Computed Property does not have it's own storage for the value...
so you have to have a real property backing it in some way.
What I like to do is use Computed Properties to "forward" properties
of embedded classes or controls. In the case of ContainerControls, I
forward properties of controls that I would like to edit directly...
like TextFont and TextSize for an embedded EditField control.
Another use is that I like combining private properties into a
Dictionary instance and then provide access to these properties via
Computed Properties.
In my opinion, Computed Properties are most useful when something
needs to happen when the value changes. For example if you have a
BackgroundColor property for a custom control, you will need to
redraw the control to reflect the change.
So how to use:
Private mBackColor As Color
BackgroundColor As Color (As computed Property)
Get
Return mBackColor
Set
If (value <> mBackColor) Then
mBackColor = value
Me.Refresh
End If
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>