Results 1 to 5 of 5

Thread: Easy form question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Location
    Seattle, WA USA
    Posts
    216

    Easy form question

    Ok I need some quick help with a form problem. I'm trying to change the Title of the form using code. Whenever I load the form though, it still comes up as "Form1"
    VB Code:
    1. Public Class Form1
    2.     Inherits System.Windows.Forms.Form
    3.    
    4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.         Dim frm As New Form1()
    6.         frm.Text = "TextChanged"
    7.     End Sub
    8. End Class
    What am I doing wrong?

    -- Ethan --
    VB6, VB.NET, C#, SQL, XML, ADO.NET, ASP.NET, HTML.
    MCP & A+ Certified. Looking for a job in the Seattle, WA area.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Me.Text = "TextChanged"

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    because you are creating a NEW instance of form1 and naming it but you never show it.

    Should be Me.Text = "blah" like athley said
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Location
    Seattle, WA USA
    Posts
    216
    What if I want to change the .Text of a form from within another form? Then I can't use "Me.Text = 'whatever'". So what should I do? .NET is going to take some getting used to.

    -- Ethan --
    VB6, VB.NET, C#, SQL, XML, ADO.NET, ASP.NET, HTML.
    MCP & A+ Certified. Looking for a job in the Seattle, WA area.

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    No, you would'nt use Me.Text. You would have to pass a reference of that form to the next form, then change what you want.
    Dont gain the world and lose your soul

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