0

Hi,
I have one form which is login form which contains username and image browsing field. Now in

Login.cs

private void LoadGameButton_Click(object sender, EventArgs e)
            {
      TicTacToe tic=new TicTacToe(usernametextBox.Text,imgTextbox.Text);
                if (imgTextbox.Text.Equals(""))
                {
                    MessageBox.Show("Please select any image");
                    return;
                }
                else
                {
                    tic.Show();
                   // this.Hide();
                }
                }

In TicTacToe.cs

public TicTacToe(String strText,string img)
        {
            InitializeComponent();
            if (strText.Equals(""))
            {
                label2.Text = "Guest";
            }
            else
            {
                label2.Text = strText;
                
            }
            
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            //pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
            
            pictureBox1.Load(img);
            pictureBox1.Refresh();
        }

Question is:
I defined two picturebox fields on this form where i can load 2 people images but now how to write the code so that once the user is logged in image will come in one picturebox and when second user is logged in it will come in second picturebox and after that login form should be hidden.

Please help?

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by JerryShaw
0

There seems to be a lot of gaps in your question, but I will take a stab at it. You have a load Game button and you need player 1 and Player 2 to login. I assume both login on the same form while it is open. Once both players are selected, then you want to instantiate the game and have those players pictures appear on the main screen (the Game).

First, do not instantiate TicTacToe until you have both players assigned with names and images on this login screen. So disable the loadgame button until both players are set. Then when you instantiate TicTacToe from the loadgame event handler, provide 4 parameters (both player names and images) instead of just two.

Does that make sense ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.