Passing Text from one form to another...Problem!

Ok, I'm very new to C# and have only been programming C++ for about 6 months. I've never programmed in VB or Java so making a Window's Application is pretty foreign to me. Here's my problem.

I am writing a blackjack game using C#. I've got a few forms set up, and they all seem to be working correctly with what I have so far. I'm just getting started with it, so the actual "game logic" isn't implemented yet.

The first form that pops up is a simple "Enter your name" form with a text field and an OK button. The object of this form is to take the string name the user enters, store it in a variable, then, when the user clicks OK, the main game comes up and the user's name is supposed to show in the Text porperty of the user's hand. The hand itself, is all within a group_box at the bottom half of the form...but right now, the default text for the group_box is there.

Basically, how do I go about taking the input from the Enter your name form and insert it into the text property of the group_box? I've tried a few different ways with no success.

Can anyone help me out or point me in the right direction? Thanks!


  • In your main form:

    EnterNameForm newForm = new EnterNameForm();
    DialogResult dlgResult = newForm.ShowDialog();
    nameLabel.Text = newForm.NameEditCtrl.Text;

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion