c# - passing variables into another form -
I am developing a window app in C #. I have used three decimal variables: counter
, narrow
, and wide
which store different values depending on some calculations .
On clicking on a button, a message box displays these three decimal values and then exits the application.
Now I want to add another form I have three labels in which these variable values should be shown. Please explain, how can I pass those variables in the next to display in different labels?
new form ...
public class calculation content form: form { Public counting field () {} Public Decimal Counter {Set {labelCounter.Text = value.ToString (); }} Public Decimal Broad {Set {labelBroad.Text = value.ToString (); }} Public decimal margin {set {labelNarrow.Text = value.ToString (); }} Private Zero OkButton_Click (Object Sender, EventArgs E) {// This form will close (similar to the right click on the message box) DialogResult = DialogResult.OK; }}
Then within your existing form button click handler ...
Private Zero MyButton_Click (Object Sender, EventArgs e) {CalculationResultForm resultForm = New CalculationResultForm (); the resulting. Counter = _counter; the resulting. Narrow = _narrow; As a result.out = _broad; the resulting. Showdialog (); Application.Exit (); }
Comments
Post a Comment