2017-09-11 6 views
-1

다음 양식으로 이동하려면 DialogResult를 사용하고 라디오 단추가있는 다음 양식에서는 보이지 않거나 보이지 않는 컨트롤을 선택하고 싶습니다. 내가 라디오를 사용할DialogResult를 Windows에서 사용하십시오. 폼 응용 프로그램 C#

private void Form1_Load(object sender, EventArgs e) 
 
{ 
 
    First_form first = new First_form(); 
 
    if (first.ShowDialog() == DialogResult.OK) 
 
    { 
 
    MessageBox.Show("Device Found!"); 
 
    serialPort1 = first.comport; 
 
    first.comport.Close(); 
 
    serialPort1.Close(); 
 
    serialPort1.Open(); 
 
    timer1.Enabled = true; 
 
    timer2.Enabled = true; 
 
    pictureBoxConect.Visible = true; 
 
    label_conect.Visible = true; 
 
    } 
 
    else 
 
    { 
 
    MessageBox.Show("Not Device Found!"); 
 
    pictureBoxDisconect.Visible = true; 
 
    label_disconect.Visible = true; 
 
    } 
 
}

:

this.DialogResult = DialogResult.OK; 
 
loader.Enabled = false; 
 
this.Close(); 
 
return;
하고 다음 형식으로 내가 이것을 사용 첫 번째 양식에서 나는이 코드를 사용 제 1 입력 양식의 버튼

+0

질문이 명확하지 않습니다. – Hybridzz

+0

두 가지 양식에서 일부 공용 속성을 선언하고 동일한 네임 스페이스에서 액세스 할 수 있습니다. 또는 생성자에 매개 변수를 전달하여이 작업을 수행 할 수 있습니다. –

답변

0

시도해보십시오.

if (radioButton.Checked == true) 
    this.DialogResult = DialogResult.Yes; 
else 
    this.DialogResult = DialogResult.Cancel;