0

助けてください。ハングマン ゲームのコードを書いています。フォームのアイコンを変更したいだけです。アイコン プロパティを使用して試してみましたが、うまくいきません。また、次のプロジェクト-->プロパティ--->アイコンとマニフェストを実行しますが、機能しません。これは、完全に機能するゲームの私のコードです:

                  private void button1_Click(object sender, EventArgs e)
            {

                stage_count++;//strat from stage 1

               if (!int.TryParse(textBox1.Text.ToString(), out value))
                  return;//if user inter non_integer value do no thing and wait for new entry

               if (key ==value )//directly if user guesses the key he/she wins the game 
               {
                   //view the seventh picture in hangman game
                   button1.Enabled = false;
                   textBox1.Text = "";
                   textBox1.Enabled = false;
                   pictureBox7.Visible = true;
                   pictureBox1.Visible = false;
                   pictureBox2.Visible = false;
                   pictureBox3.Visible = false;
                   pictureBox4.Visible = false;
                   pictureBox5.Visible = false;
                   pictureBox6.Visible = false;

                   groupBox1.Visible = true;

                   label1.Text = "Great... You Got It ^_^ ";
               }




                   if (key > value)//guide the user to the correct answer
                        label1.Text = "Should Be Greater than" + value.ToString();

                   if (key < value)//guide the user to the correct answer
                        label1.Text = "Should Be Less than" + value.ToString();
                   if (key != value)
                   {
                       switch (stage_count)
                       {//this switch statement used to do some thing in each stage
                           case 1:
                               //view the first picture in hangman game
                               pictureBox1.Visible = true;
                               pictureBox2.Visible = false;
                               pictureBox3.Visible = false;
                               pictureBox4.Visible = false;
                               pictureBox5.Visible = false;
                               pictureBox6.Visible = false;
                               pictureBox7.Visible = false;
                               break;
                           case 2:
                               //view the second  picture in hangman game
                               pictureBox1.Visible = false;
                               pictureBox2.Visible = true;
                               pictureBox3.Visible = false;
                               pictureBox4.Visible = false;
                               pictureBox5.Visible = false;
                               pictureBox6.Visible = false;
                               pictureBox7.Visible = false;

                               break;
                           case 3:
                               //view the third picture in hangman game
                               pictureBox1.Visible = false;
                               pictureBox2.Visible = false;
                               pictureBox3.Visible = true;
                               pictureBox4.Visible = false;
                               pictureBox5.Visible = false;
                               pictureBox6.Visible = false;
                               pictureBox7.Visible = false;

                               break;
                           case 4:
                               //view the fourth picture in hangman game
                               pictureBox1.Visible = false;
                               pictureBox2.Visible = false;
                               pictureBox3.Visible = false;
                               pictureBox4.Visible = true;
                               pictureBox5.Visible = false;
                               pictureBox6.Visible = false;
                               pictureBox7.Visible = false;

                               break;
                           case 5:
                               //view the fifth  picture in hangman game
                               pictureBox1.Visible = false;
                               pictureBox2.Visible = false;
                               pictureBox3.Visible = false;
                               pictureBox4.Visible = false;
                               pictureBox5.Visible = true;
                               pictureBox6.Visible = false;
                               pictureBox7.Visible = false;

                               break;

                           default:
                               //view the sixth picture in hangman game
                               //it's the last try so diable the button and show the result
                               button1.Enabled = false;
                               textBox1.Text = "";
                               textBox1.Enabled = false;
                               groupBox1.Visible = true;
                               label1.Text = "YOU  LOSE ,, IT  WAS :    " + key.ToString();
                               pictureBox1.Visible = false;
                               pictureBox2.Visible = false;
                               pictureBox3.Visible = false;
                               pictureBox4.Visible = false;
                               pictureBox5.Visible = false;
                               pictureBox6.Visible = true;
                               pictureBox7.Visible = false;

                               break;



                       }//end switch
                       //to make empty focused textbox 
                       textBox1.Text = "";
                       textBox1.Focus();


                   }//end if   


            }

            private void groupBox1_Enter(object sender, EventArgs e)
            {



            }

            private void radioButton1_CheckedChanged(object sender, EventArgs e)
            {// if user want to playe new game the programm must enables the important controls and 
                //make the visible property equals to false for all the pictures boxes

                if (radioButton1.Checked == true)
                {
                    stage_count = 0;
                     key = (1 + obj.Next(99));
                    textBox1.Enabled = true;
                    textBox1.Text = "";
                    textBox1.Focus();
                    button1.Enabled = true;
                    label1.Text = "Guess a number btween 1-100";
                    pictureBox1.Visible = false;
                    pictureBox2.Visible = false;
                    pictureBox3.Visible = false;
                    pictureBox4.Visible = false;
                    pictureBox5.Visible = false;
                    pictureBox6.Visible = false;
                    pictureBox7.Visible = false;

                    groupBox1.Visible = false;
                    radioButton1.Checked = false;
                }
            }

            private void radioButton2_CheckedChanged(object sender, EventArgs e)
            {
                // if user won't to play again just close it 
                if (radioButton2.Checked == true)
                {
                    radioButton2.Checked = false;
                    this.Close();
                }
            }
        }
    }
4

6 に答える 6

1

プロパティウィンドウに移動し、 「アイコン」プロパティを独自のアイコンに変更します。

于 2013-11-07T09:16:08.993 に答える
0

プロジェクトのプロパティで設定する必要があります。

VisualStudio で F5 キーを押してアプリケーションを起動してもアイコンが表示されない場合は、Debug-(Release) ディレクトリを確認してください。正しいアイコンがあるはずです

于 2013-11-07T09:19:29.443 に答える