Accessing other forms

This is a discussion on Accessing other forms within the C# Programming forums, part of the General Programming Boards category; How can I, from form1's code, access form2, to for example change the title of form2 etc? I type in ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    98

    Accessing other forms

    How can I, from form1's code, access form2, to for example change the title of form2 etc? I type in "form2.", and the options it brings up having nothing to do with changing the properties of form2. Please help! (I'm using C# 2005 express).

  2. #2
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    you can create a public function in form2 to do whatever you want so you can call it and send it whatever, like if you have a label in form 2 you could create a public SetLabel(string) function in form 2 and then call it from form 1 by calling

    Code:
    form2.SetLabel("new label text");
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    98
    Ok thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2009, 05:40 AM
  2. prob with multiple forms accessing header file
    By silkyt in forum Windows Programming
    Replies: 7
    Last Post: 11-03-2007, 05:14 PM
  3. C# Game using Forms
    By ejohns85 in forum C# Programming
    Replies: 1
    Last Post: 12-16-2006, 05:35 PM
  4. Two forms showing at once
    By Tperry23 in forum C# Programming
    Replies: 0
    Last Post: 06-08-2005, 12:51 AM
  5. accessing windows forms textbox properties
    By luigi40 in forum C# Programming
    Replies: 5
    Last Post: 04-19-2005, 05:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21