So basically i have two forms. In the first one i have label that I am using to display calculated value and a button that shows Form2. Form 2 contains "save button" and numericupdown control that is used to enter a value.
The question is, how to save "data" in a form by pressing "save button" and then pass them to a proper class?
BaseForAll
class BaseForAll
{ //Class that im using as a "base class" for other classes
private decimal x;
public decimal X
{
get
{
return x;
}
set
{
value = x;
}
}
}
baza2
class baza2:BaseForAll
{ // Calculating a value.
private decimal Xs()
{
decimal resultOfX = X / 10;
return resultOfX;
}
public decimal ResultOfXs
{
get
{
decimal resultOfXs = Xs();
return resultOfXs;
}
}
}
Form2
public partial class Form2 : Form
{
baza Baza;
public Form2()
{
InitializeComponent();
Baza = new baza((decimal)numericUpDown1.Value);
}
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
Baza.X = (decimal)numericUpDown1.Value;
}
}
Form1
public partial class Form1 : Form
{
Form2 frm;
baza2 Baza2 = new baza2();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
frm = new Form2();
if (frm.ShowDialog() == DialogResult.OK)
{
/// ??????
}
}
private void displaylabel()
{
decimal displayX = Baza2.ResultOfXs;
label1.Text = displayX.ToString();
}
}
baza
class baza:BaseForAll
{
public baza(decimal X)
{
this.X = X;
}
}