Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In C#, i wanna create two forms. And in first form if user enter the value in text box the second form to be loaded. For example if the user enter 3, in second form 3*3 matrices of text boxes to be displayed. Then the user to enter the values in the text boxes. If button is clicked some calculation to be done and it to be display in answer text boxes. Can you anyone please help me. Thanks in advance.
Posted

1 solution

The easiest way is to create a constructor for the second form that takes an integer value (or two integers - x and y for future expansion) and uses that to construct the appropriate data for the user to fill in. You also create a Property in the matrix form which returns the result. You then read the value in the first form, convert it from a string to an int, and construct the new form instance with the number:
int size;
C#
if (!int.TryParse(myTextBox.Text, out size))
   {
   // Report problem to user - it's not a number!
   }
else
   {
   frmMatrix fm = new frmMatrix(size, size);
   fm.ShowDialog();
   myResultTextBox.Text = fm.Result.ToString();
   }


Exactly how to display it in the matrix form is up to you - there are a lot of possible options you could use. Any idea what you would be comfortable with?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900