关于gui(窗口应用程序) [英] regarding gui(window application)

查看:107
本文介绍了关于gui(窗口应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生

我想知道如何添加两个数字.在gui中...如果我有一个textbox1和textbox2,并且我必须在两个文本中都添加值,并想在第三个文本框中显示结果.... textbox3 ...单击单击按钮


我正在面对prblm plz帮助我.........

sir

i want to know how to add two nos. in gui...if i havee one textbox1 and textbox2 and i have to add the values in both the text and want to show the result in third text box....textbox3...on clicking on click button


i m facing prblm plz help me.........

推荐答案

SHALU DIXIT写道:
SHALU DIXIT wrote:

im面对prblm plz可以帮助我.........

i m facing prblm plz help me.........


您面临什么问题?

按照看起来,您试图添加两个文本框的文本并在第三个文本框中显示它.您可以对同一事件使用各种事件.使用文本框的textchange事件进行加法,然后将其显示在第三位的操作.


What problem you are facing?

As per what it seems, you are trying to append texts of two textboxes and show it in third. You can use various events for the same. Use textchange event of the textboxes to do the operation of adding up and then displaying it in third.


这是答案-

公共button_click()
{
TextBox3.Text = Convert.ToInt32(TextBox1.Text)+ Convert.ToInt32(TextBox2.Text);
}

问候,

Nilesh Shah.
Here is answer -

public button_click()
{
TextBox3.Text = Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text);
}

Regards,

Nilesh Shah.


Hello Shanlu,

我已经使用C#来解决您的查询,因为您没有提及C#或VB.NET之类的任何标签,或者根据您的要求反正她的代码...

我觉得您是个初学者,所以请抢先阅读一本有关C#的好书并开始编码,
我首先将输入的文本转换为整数值,然后将其添加到第三个文本框中显示其结果


Hello Shanlu,

i have used C# to solve your query because u didn''t mention any tags like C# or VB.NET or something anyways hers your code as per your requirement...

I feel you are a beginner so grab a good book for C# and start coding,
i have first converted the text entered into integer value and then added them displaying their result at third textbox


private void button1_Click(object sender, EventArgs e)
        {
            //i have used try catch so that if the user tries characters a message will be displayed
            try
            {
                // adding two numbers here
               int x= int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
                // display result in 3rd textbox
               textBox3.Text = x.ToString(); // integer is casted to string
            }
            catch (Exception ex)
            {
//show messagebox
                MessageBox.Show("Invalid text format for addition");
                //clear the textboxes
                textBox1.Clear();
                textBox2.Clear();
            }
        }



现在,如果您希望在文本框中仅输入数字,则可以在此处引用我的答案之一
Radix的数字文本框

一旦找到有用的答案,就对我的答案进行评分
谢谢&问候
基:rose:



Now if you want that in your textboxes only number must be entered then you can refer to one of my answers here
Numeric Textbox by Radix

Do rate my answer once you find it useful
Thanks & Regards
Radix :rose:


这篇关于关于gui(窗口应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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