# Setting form name with user input

This topic is 2193 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So I want my users to be able to create a file, and name it, then while the program is running they can see the name of the file they're using, when creating a new file they're asked to input a name for it, and once accepted, the form will load with their new file, setting the form name (or a label) to the name they've input.

My problem at the moment is that, when I take the text box text and convert to a string, then set the name of the new form to that string, it does nothing. the code compiles and runs without error, but does nothing. I've trawled through the MSDN documentation, however, none of it seems to handle anything remotely like this that I can find - only converting things like integers into strings, etc. If I try to directly input the text box text anywhere it throws errors that it can't be implicitly converted into a string.

Anyway, here's the code:
 LeagueView StartNewLeague = new LeagueView(); string NameString; //NewLeagueName.Text.ToString(); //This line seems to make no difference, moved down one. //this converts newleaguename.text into a string and makes NameString = that text (i.e. the name the user has input) NameString = NewLeagueName.Text.ToString(); //this sets the name of the new league to the name the user has input StartNewLeague.Name = NameString; //only it actually doesn't, as it does nothing whatsoever. StartNewLeague.Show();

Does anyone have any ideas about how to set the name of the new form window (or alternatively to set the name of a label within the new form) ?

##### Share on other sites
When you create a new form, try going to th Form.Designer.cs and change the property of label into public, that way you should be able to interact with it from other forms. I think the same thing can be done for Form's text (caption) but I haven't tried it. I think what you are trying to do is to pass data between forms - this is the link that explains how to do that. Hope this helps.

##### Share on other sites
It is because you are not using the right property. If you are using WinForms, then the property is "Text", so you would have StarNewLeague.Text = "your custom name" in there, here is where I found this answer:
http://stackoverflow.com/questions/5104175/how-do-you-change-the-text-in-the-titlebar-in-winforms

If you are using WPF, then again, the property is "Title" and not Name.

##### Share on other sites
Thanks, that's exactly the kind of thing I'm looking for.