多行文本框的总计 [英] Total of a multi line text box

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

问题描述

大家好,我的Windows窗体应用程序中有两个文本框。一个是多行文本框,一个是单行文本框。我想在多行文本框中输入许多不同的值(每行一个值)。那么我想要的是使多行文本框中的所有
值相加并在单行文本框中显示为一个值AUTOMATICALLY。这样做最好没有按钮,但如果没有选择按钮也可以。

Hi guys, I have two text boxes in my windows form application. One is a multi line text box, one is a single line text box. I would like to enter a lot of different values in the multi line text box (one value per line). Then what I want is so that all the values from the multi line text box are added up and displayed in the single line text box as one value AUTOMATICALLY. This would be best done without a button, however if there isn't a choice a button would do as well.

感谢您帮助我使用我的代码!

Thank you for helping me with my code!

问候,Exteez

推荐答案

您可以为多行TextBox处理LostFocus事件:

You could for example handle the LostFocus event for the multi-line TextBox:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            multiLinetextBox.LostFocus += MultiLinetextBox_LostFocus;
        }

        private void MultiLinetextBox_LostFocus(object sender, EventArgs e)
        {
            singleLinetextBox1.Text = multiLinetextBox.Text.Replace(Environment.NewLine, "");
            multiLinetextBox.Text = ""; //clear
        }
    }

然后当您填充单行TextBox时走出多行TextBox。

Then the single-line TextBox will be populated when you step out of the multi-line TextBox.

希望有所帮助。

请记住通过将有用的帖子标记为答案来关闭你的主题然后开始如果你有一个新问题,一个新的主题。请不要在同一个帖子中提出几个问题。

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


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

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