2014-01-23 2 views
0

questionNr이 1로 설정되어 있어도 questionLabel뿐만 아니라 ans1-4의 .Text 속성도 변경되지 않습니다. 어떤 도움을 주시면 감사하겠습니다. 하위 질문으로, if (ans1.Clicked = true) 행을 따라 무언가를 할 수 있습니까? 당신이 question() 메소드를 호출텍스트 속성이 변경되지 않습니까?

public partial class Form1 : Form 
    { 
    int pointCounter = 0; 
    private SoundPlayer _soundPlayer; 
    int questionNr = 1; 

    public Form1() 
    { 
     InitializeComponent(); 
     _soundPlayer = new SoundPlayer("song.wav"); 
    } 

    private void pictureBox1_Click(object sender, EventArgs e) 
    { 
     System.Diagnostics.Process.Start("http://rads.stackoverflow.com/amzn/click/B007AFS0N2"); 
    } 

    private void Form1_Load(object sender, EventArgs e) 
    { 
     _soundPlayer.PlayLooping(); 
    } 


    private void label1_Click(object sender, EventArgs e) 
    { 

    } 

    private void muteButton_Click(object sender, EventArgs e) 
    { 
     if (muteButton.Text == "Mute") 
     { 

      muteButton.Text = "Unmute"; 
      _soundPlayer.Stop(); 
     } 

     else 
     { 
      muteButton.Text = "Mute"; 
      _soundPlayer.PlayLooping(); 
     } 
    } 

    private void playButton_Click(object sender, EventArgs e) 
    { 
     ans1.Visible = true; 
     ans2.Visible = true; 
     ans3.Visible = true; 
     ans4.Visible = true; 
     playButton.Visible = false; 

    } 

    public void question() 
    { 
     if (questionNr == 1) 
     { 
      questionLabel.Text = "What is Chuck's full name?"; 
      ans1.Text = "Charles Irving Bartowski"; 
      ans2.Text = "Charles Richard Bartowski"; 
      ans3.Text = "Charles Luke Bartowski"; 
      ans4.Text = "Zachary Strahovski"; 
     } 

    } 

    private void ans1_Click(object sender, EventArgs e) 
    { 

    } 

    private void ans2_Click(object sender, EventArgs e) 
    { 

    } 

    private void ans3_Click(object sender, EventArgs e) 
    { 

    } 

    private void ans4_Click(object sender, EventArgs e) 
    { 

    } 
} 

}

+0

여기서'question() '을 (를) 호출하고 있습니까? – Blorgbeard

+0

죄송합니다, 무슨 뜻인지 모르겠지만 전화해야합니까? 만약 그렇다면 어떻게 –

+0

내 겸손한 생각에 나는 C#에서 튜토리얼을 읽은 다음 다시 오버 플로우 스택으로 돌아와야한다고 생각한다. – venerik

답변

0

양식. 먼저 필요한 곳에서 해당 메소드를 호출하십시오. 예 : FormLoad/버튼

public Form1() 
    { 
     InitializeComponent(); 
     _soundPlayer = new SoundPlayer("song.wav"); 
     question(); 
    } 

당신이 당신의 폼로드 이벤트에 브레이크 포인트를 넣어 경우가 좋은 시도하고 볼 etc..Then 클릭 어떻게의 흐름에 대한 아이디어를 얻을 수 있습니다 executed.Then 코드 당신의 코드.

관련 문제