-1

I want to use DialogResult to go to next Form and visible or invisible any control in next form with radio button is checked. In the first form I use this code:

this.DialogResult = DialogResult.OK;
loader.Enabled = false;
this.Close();
return;

and in the next form I use this:

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;
  }
}

i want to use radio button in myfirst form

J.SMTBCJ15
  • 471
  • 6
  • 20
Mr.AA
  • 15
  • 1
  • 5
  • question not clear. – Sin Sep 11 '17 at 06:09
  • You can do this by declaring some public properties in both forms and access them within the same namespace. Or you can do this with the help of passing parameters to constructor. – J.SMTBCJ15 Sep 11 '17 at 06:11

1 Answers1

0

Try this,

if (radioButton.Checked == true)
   this.DialogResult = DialogResult.Yes;
else
   this.DialogResult = DialogResult.Cancel;
Zan
  • 116
  • 2
  • 7