Adding controls to Extended Form class

Cep

Member
Joined
Apr 29, 2008
Messages
11
Programming Experience
1-3
Hello there,

I am currently extending the form class to create a form template class for forms in my project. One of the things I want to do is product a label on each form with my name in the bottom right at about -10, -10 pixels from the border of the form.

The problem I seem to be having is that each child object can have a different size and my template class has a form with 300 x 300 size. So as you may have guessed when the form object is created with a size of 100 x 200, my dynamic label is appearing at 290, 290 still.

Here is my code,

VB.NET:
Public Class FadingForm

    Public Sub New()
        MyBase.New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.        
        MyClass.AddCopyrightLabel()
        Me.Text = "My Form"
        Me.Opacity = 0
        Me.FadeTimer.Enabled = True
        Me.BackColor = Color.LightBlue
        Me.Icon = GetEmbeddedIcon("MyNamespace.my.ico")

    End Sub

    Private Sub AddCopyrightLabel()

        Dim CopyrightLabel As Label = New Label

        CopyrightLabel.AutoSize = True
        CopyrightLabel.Text = "My name is here"

        CopyrightLabel.Location = New Point(MyClass.Width - 10, MyClass.Height - 10)

        Me.Controls.Add(CopyrightLabel)

    End Sub

    Private Sub FadeTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FadeTimer.Tick
        If Me.Opacity < 1 Then
            Me.Opacity += 0.05
        Else
            Me.FadeTimer.Enabled = False
        End If
    End Sub

    Private Function GetEmbeddedIcon(ByVal strName As String) As Icon
        Return New  _
    Icon(System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream( _
         strName))
    End Function

End Class

The problem is this line I think but I am not sure what to put there instead.

VB.NET:
CopyrightLabel.Location = New Point(MyClass.Width - 10, MyClass.Height - 10)
 
I posted a VB.Net 2.0 project since your forum profile says you're using that. Happy you sorted things out.
 
Back
Top