Results 1 to 4 of 4

Thread: [RESOLVED] [2008] property grayed out.

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Resolved [RESOLVED] [2008] property grayed out.

    I am trying to create a "base" form from which all my forms will inherit from.

    I am trying to put a logo (taken from the internet) and a text on the form.

    The text called "formTitleText". I think i know where I am making the mistake.

    vb.net Code:
    1. Imports System.Drawing.Drawing2D
    2.  
    3. Public Class BaseFormClass
    4.     Inherits System.Windows.Forms.Form
    5.     Private _formTitleText As String
    6.  
    7.     Public Property TitleText()
    8.         Get
    9.             Return _formTitleText
    10.         End Get
    11.         Set(ByVal value)
    12.             _formTitleText = value
    13.         End Set
    14.     End Property
    15.  
    16.     Public Sub New()
    17.         MyBase.New()
    18.         Me.Text = "Cool, inherited form"
    19.         Me.BackColor = Color.White
    20.         If String.IsNullOrEmpty(_formTitleText) Then
    21.             _formTitleText = "####"
    22.         End If
    23.     End Sub
    24.  
    25.     Public Sub New(ByVal formTitleText As String)
    26.         MyBase.New()
    27.         Me.Text = "Cool, inherited form"
    28.         Me.BackColor = Color.White
    29.         If String.IsNullOrEmpty(_formTitleText) Then
    30.             _formTitleText = "####"
    31.         Else
    32.             _formTitleText = formTitleText
    33.         End If
    34.     End Sub
    35.  
    36.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    37.         'MyBase.OnPaint(e)
    38.         Dim fnt As New Font("Verdana", 16)
    39.         g.DrawString(_formTitleText, fnt, New SolidBrush(Color.Red), 14, 10)
    40.  
    41.     End Sub
    42.  
    43.  
    44. End Class

    When I build the project, and use it in my main form (which I changed by showing the designer file and inheriting my class) the property, though it shows up, is grayed out and I cant change it.

    However, I can change it on the onload event.
    Code:
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.TitleText = "New"
        End Sub
    Is it because I am using it in the 'onpaint' event?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width