Καλησπέρα και καλός Ήλθες στην παρέα μας,
Στο Ψητό και εγώ:
Αυτό που θές γίνετε σωστα με Event. (Αν δεν έχεις γνώσει απο Events πες μου να κάνω clarification)
Πρέπει λοιπόν η Form2 να έχει ένα event το οποίο θα "πιάνει" η Form1 και θα αλλάζει την τιμή του TextBox, Πάμε λοιπόν να δουμε πώς μπορουμε να το κάνουμε αυτό.
Μεσα στην Form2:
using.....
public delegate void UpDownChanged(string val);
public partial class Form2: Form
{
public event UpDownChanged ValueChanged;
public Form2()
{
InitializeComponents();
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
}
....
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
if (ValueChanged != null)
ValueChanged(numericUpDown1.Value.ToString());
}
}
Τώρα μέσα στην Form1 εκεί που κάνεις :
public partial Class Form1:Form
{
...
private void Button1_Click (object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.ValueChanged +=new UpDownChanged(UpDownChanged);
frm2.Show();
}
private void caseAssignment1_ev(string val)
{
this.textBox1.Text = val;
}
}
Hope that helps
Nassos
"Success is the ability to go from one failure to another with no loss of enthusiasm."
Winston Churchill
"Quality means doing it right when no one is looking."
Henry Ford