使用文本框的矩阵 [英] Matrices using text box

查看:82
本文介绍了使用文本框的矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中,我想创建两种形式。并且在第一种形式中,如果用户在文本框中输入要加载的第二种形式的值。例如,如果用户输入3,则在第二种形式的3 * 3矩阵的文本框中显示。然后用户在文本框中输入值。如果单击按钮,则要进行一些计算并将其显示在答案文本框中。你能帮助我吗?在此先感谢。

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.

推荐答案

最简单的方法是为第二种形式创建一个构造函数,该构造函数采用整数值(或两个整数 - x和y用于将来的扩展)并使用它来构造用户填写的相应数据。您还以矩阵形式创建一个返回结果的属性。然后,您将读取第一种形式的值,将其从字符串转换为int,并使用数字构造新的表单实例:

int size;

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;
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?


这篇关于使用文本框的矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆