Hello,
I'm right newbe in c# but I have big problem with passing data between forms.
Below code:
[FORM2]:
So for me all should be working, but in [FORM1] after changing value of numericupdown in form2 int uwminuty doesn't change its vaule... so [FORM1]
button10 always show old value! please help me to fix it! THANK YOU!
I forgot to add that messagebox from button1 in form2 shows good values of opuwminuty and main.uwminuty.
I'm right newbe in c# but I have big problem with passing data between forms.
Below code:
[FORM2]:
Code:
public Form1 main = new Form1();
public int opuwminuty;
public Form2()
{
InitializeComponent();
numericUpDown1.Value = main.uwminuty;
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
opuwminuty = Convert.ToInt32(numericUpDown1.Value);
try { opuwminuty = Convert.ToInt32(numericUpDown1.Value); }
catch (Exception) { MessageBox.Show("pieprzy się w numericUpDown1"); }
MessageBox.Show("opuwminty =" + opuwminuty + ", a main.uwminuty" + main.uwminuty);
}
private void button1_Click(object sender, EventArgs e)
{
main.uwminuty = opuwminuty;
main.numericUpDown1.Value = opuwminuty;
try { main.uwminuty = opuwminuty; }
catch (Exception) { MessageBox.Show("pieprzy się w button1"); }
MessageBox.Show("opuwminty =" + opuwminuty + ", a main.uwminuty" + main.uwminuty);
//this.Close();
}
Code:
public int uwminuty;
private void button10_Click(object sender, EventArgs e)
{
MessageBox.Show("uwminuty = " + uwminuty);
}
I forgot to add that messagebox from button1 in form2 shows good values of opuwminuty and main.uwminuty.
Comment