在 Visual C# 中的 TextBox/Label 中显示 int 变量 [英] Displaying an int variable in TextBox/Label in Visual C#

查看:60
本文介绍了在 Visual C# 中的 TextBox/Label 中显示 int 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建我的第一个 C# 项目,但我找不到在文本框或标签中显示整数变量的方法.我使用的是 Visual C# 和 Visual Studio 2013.

I am creating my first C# project, but I can't find a way to display an integer variable in a TextBox or Label. I am using visual C# and Visual Studio 2013.

我使用 C++ 已经有一段时间了,我会直觉地使用 'cout',但我不知道把 fe 放在哪里:textBox4.text = cal(其中 cal 是变量).

I have been using C++ for quite a while and I would intuitively use 'cout', but I have no idea where to put fe: textBox4.text = cal (where cal is variable).

推荐答案

但我不知道把fe放在哪里:textBox4.text = cal(其中cal是变量).

but I have no idea where to put fe: textBox4.text = cal (where cal is variable).

您应该将此代码放在方法中.它可以是Form_Load事件,也可以是Button点击,例如添加一个按钮使用设计器(从工具箱拖放)到您的表单,双击您的按钮并将此代码放入您的按钮单击事件中:

You should put this code inside of a method.It can be Form_Load event, or a Button click, for example add a button to your form with designer (drag and drop from toolbox),double click your button and put this code inside of your button click event:

textBox4.Text = cal.ToString();

这篇关于在 Visual C# 中的 TextBox/Label 中显示 int 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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