为什么这段代码不起作用? [英] Why is this code not working?

查看:66
本文介绍了为什么这段代码不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是c#编程的新手

但是每当我在文本框中输入Adam时,即使我没有点击button1,也会显示消息框,但是复选框正常使用button1请帮助我。











Hello, i am new to c# programming
but whenever i type Adam in the textbox the messagebox shows up even though i did not click button1, But the checkbox works normally with button1 please help me.





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace C_tutorials
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int i=0;

            if (textBox1.Text == "Adam" || checkBox1.Checked)

                MessageBox.Show("hello");


        }


    }
}

推荐答案

button1事件连接到textbox1和checkbox1
button1 event was wired to textbox1 and checkbox1


这篇关于为什么这段代码不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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