textbox -usercontrol problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Agnes

    #1

    textbox -usercontrol problem

    I create my own usercontrol which is [Inherits
    System.Windows. Forms.TextBox], my purpose is set all textbox's font into the
    same. Now , I can do it by using the following code
    Protected Overrides Sub InitLayout()
    Me.Font = New System.Drawing. Font("SimSun", 8)
    .........
    However, during design mode I want to set the font into larger size e.g font
    size 9, I can run it sucessfully in the 1st time, if I amend the form during
    design mode again, the font size changed back to '8' again,
    Please help `~


  • Charlie

    #2
    RE: textbox -usercontrol problem

    You could shadow the Font property of the base control in the inherited control

    Private _Font As Font = New Font("Times", 10, FontStyle.Regul ar)
    Public Shadows Property Font() As Font
    Get
    Return Me._Font
    End Get
    Set(ByVal Value As Font)
    Me._Font = Value
    MyBase.Font = Value
    End Set
    End Property

    Also, override OnCreateControl in your inherited control.

    Protected Overrides Sub OnCreateControl ()
    MyBase.Font = Me.Font
    MyBase.OnCreate Control()
    End Sub

    cfarrier@charle sfarriersoftwar e.com



    "Agnes" wrote:
    [color=blue]
    > I create my own usercontrol which is [Inherits
    > System.Windows. Forms.TextBox], my purpose is set all textbox's font into the
    > same. Now , I can do it by using the following code
    > Protected Overrides Sub InitLayout()
    > Me.Font = New System.Drawing. Font("SimSun", 8)
    > .........
    > However, during design mode I want to set the font into larger size e.g font
    > size 9, I can run it sucessfully in the 1st time, if I amend the form during
    > design mode again, the font size changed back to '8' again,
    > Please help `~
    >
    >
    >[/color]

    Comment

    Working...