Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my game I have 2+ forms and 4+ usercontrols. Where should I declare, lets say a textbox that I use in form2, but I need to modify it in form1.

Should I make them public in their own form/usercontrol or should I make a static class with all the controls?

(Edited to clarify my question) I want to know the most used and flexible way.

share|improve this question
From the FAQ: "Would a professional game developer give me a better/different/more specific answer to this question than other programmers?" I don't think so. – user744 Aug 14 '11 at 15:53
This belongs at stackoverflow. – DuckMaestro Aug 14 '11 at 19:00
@Joe Wreschnig: but but... a game programmer would optimize for speed, then everything is public members (save function calls), no? :) – jv42 Aug 15 '11 at 7:28
up vote 2 down vote accepted

I think I would make the actual TextBox private in its Form, then expose functionality (like get/set text) using either methods or properties, depending on 'obviousness' factor, ie:

public string Text1
    get { return myTextBox1.Text; }
    set { myTextBox1.Text = value; }


public void SetTextFromVars(int var1, DateTime var2)
    myTextBox1.Text = String.Format("Hey, I have got {0} objects since {1}", var1, var2);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.