Jump to content
  • Advertisement
Sign in to follow this  
Malazar

Setting form name with user input

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!