Jump to content
  • Advertisement
Sign in to follow this  
shawnre

Grabbing textbox values from another form

This topic is 3653 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

Hello all, I am in the process of creating a tile based game editor using XNA and C#. One of my menu items is of course creating a new layer on the current map. This is the code that loads a new form when the user clicks on new layer:
frmNewLayer newLayer = new frmNewLayer();
newLayer.ShowDialog();

tileLayer = new TileLayer(newLayer.txtLayerName.Text);
tileLayerWidth = int.Parse(newLayer.txtLayerWidth.Text);
tileLayerHeight = int.Parse(newLayer.txtLayerHeight.Text);




Simple question I suppose. I am grabbing the text values for the tileLayer, tileLayerWidth, and tileLayerHeight after the newLayer form OK button was clicked (I am checking the values of the textboxes in the forms OK button click, so the values should be valid once it returns here). So far, this method is working just fine, but I got to wondering, am I just getting lucky at this point in capturing the .Text values from the newLayer form, since the this.Close() method is called in the frmNewLayer after validating the textbox values? Thanks, Shawn *Edit* - Just to clarify, I am wondering if I am still able to retrieve those values because the GC has not ran on the form (the frmNewLayer) even though it has been closed? If that is the case, what would be a better way to do this?

Share this post


Link to post
Share on other sites
Advertisement
I don't think you're getting lucky, I think it's fine. If you're ensuring that the data has been passed (i.e. copied) before you destroy the original form then providing you don't try to refer back to the previously destroyed object then I can't immediately see any problems.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!