DELEGATED PROPERTY


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: DELEGATED PROPERTY

  1. #1
    CHICHO Guest

    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

  2. #2
    Mike Guest

    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



  3. #3
    CHICHO Guest

    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

    >



  4. #4
    Mike Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center