-
DELEGATED PROPERTY
Hello, I want to delegate the font property of the textbox , the
property procedures do work because Ive changed font properties at design
time, but when I run the program, only the name of
the font is passed, if I select bold or size 16 It wont work
at run time. Please Help.
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Dim x As New StdFont
PropBag.WriteProperty "Font", Text1.Font , x
End Sub
Public Property Get Font() As StdFont
Set Font = Text1.Font
End Property
Public Property Set Font(fNewFont As Font)
Set Text1.Font = fNewFont
PropertyChanged ("Font")
End Property
-
Re: DELEGATED PROPERTY
Do you have a Usercontrol_ReadProperty ?
Mike
"CHICHO" <chicho_chicho@hotmail.com> wrote:
>
>Hello, I want to delegate the font property of the textbox , the
>property procedures do work because Ive changed font properties at design
>time, but when I run the program, only the name of
>the font is passed, if I select bold or size 16 It wont work
>at run time. Please Help.
>
>
>Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
>Dim x As New StdFont
> PropBag.WriteProperty "Font", Text1.Font , x
>End Sub
>
>Public Property Get Font() As StdFont
>Set Font = Text1.Font
>End Property
>
>Public Property Set Font(fNewFont As Font)
>Set Text1.Font = fNewFont
>PropertyChanged ("Font")
>End Property
-
Re: DELEGATED PROPERTY
Thank you Mike;
I do have a read property , it goes like this:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Text1.Font = PropBag.ReadProperty("Font", Text1.Font)
End Sub
The property bag can accept objects as well as variables?
Thank-you
"Mike" <m_culley@one.net.au> wrote:
>
>Do you have a Usercontrol_ReadProperty ?
>
>Mike
>
>"CHICHO" <chicho_chicho@hotmail.com> wrote:
>>
>>Hello, I want to delegate the font property of the textbox , the
>>property procedures do work because Ive changed font properties at design
>>time, but when I run the program, only the name of
>>the font is passed, if I select bold or size 16 It wont work
>>at run time. Please Help.
>>
>>
>>Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
>>Dim x As New StdFont
>> PropBag.WriteProperty "Font", Text1.Font , x
>>End Sub
>>
>>Public Property Get Font() As StdFont
>>Set Font = Text1.Font
>>End Property
>>
>>Public Property Set Font(fNewFont As Font)
>>Set Text1.Font = fNewFont
>>PropertyChanged ("Font")
>>End Property
>
-
Re: DELEGATED PROPERTY
CHICHO,
>>The property bag can accept objects as well as variables?
Yes.
I have found that fonts can be a bit odd as properties in usercontrols. I
think that doing this:
Public Property Set Font(ByVal NewVal as stdFont)
Set Text1.Font=NewVal
end property
does not work correctly. All seams to go fine until you modify the font (say
making it underlined), at which time you'll get an automation error.
From memory, I wrote a CopyFont routine:
Private Sub CopyFont(ByVal DestFont as stdFont,ByVal SourceFont as stdFont)
DestFont.Name=SourceFont.Name
DestFont.Size=SourceFont.Size
etc
end sub
then make your property set like this
Public Property Set Font(ByVal NewVal as stdFont)
copyFont Text1.Font,NewVal
end property
and readprops like this
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
CopyFont Text1.Font ,PropBag.ReadProperty("Font", Ambient.Font)
End Sub
Also, you should put in the initproperties
CopyFont Text1.Font,Ambient.Font
and use Ambient.Font as the default property in the write properties also.
Hope this helps
Mike
"CHICHO" <chicho_chicho@hotmail.com> wrote:
>
>Thank you Mike;
>I do have a read property , it goes like this:
>
>
>Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
>Text1.Font = PropBag.ReadProperty("Font", Text1.Font)
>End Sub
>
>The property bag can accept objects as well as variables?
>Thank-you
>
>
>
>"Mike" <m_culley@one.net.au> wrote:
>>
>>Do you have a Usercontrol_ReadProperty ?
>>
>>Mike
>>
>>"CHICHO" <chicho_chicho@hotmail.com> wrote:
>>>
>>>Hello, I want to delegate the font property of the textbox , the
>>>property procedures do work because Ive changed font properties at design
>>>time, but when I run the program, only the name of
>>>the font is passed, if I select bold or size 16 It wont work
>>>at run time. Please Help.
>>>
>>>
>>>Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
>>>Dim x As New StdFont
>>> PropBag.WriteProperty "Font", Text1.Font , x
>>>End Sub
>>>
>>>Public Property Get Font() As StdFont
>>>Set Font = Text1.Font
>>>End Property
>>>
>>>Public Property Set Font(fNewFont As Font)
>>>Set Text1.Font = fNewFont
>>>PropertyChanged ("Font")
>>>End Property
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks