Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
1  
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
1  
@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
add comment

1 Answer

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; }
}

or...

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
add comment

Your Answer

 
discard

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.