TextBox.Text =多个单词 [英] TextBox.Text = Multiple words

查看:55
本文介绍了TextBox.Text =多个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,是否可以创建更多的单词,我创建了一个计时器,它检查文本框中输入的内容,如果输入的密码更改了图片,那么我的其他if功能不会工作,我怎么能做这样的事情:

Hello, is it possible to make more words than one, i have created a timer, which checks what is typed in a textbox, and if write password typed changes a picture, so my other if function don't work, how could i make something like this:

声明的代码,我需要这样的东西:if(metroTextBox1.Text ==" byby"," cow" ,"root",

The code of statement, i need something like this: if (metroTextBox1.Text == "byby", "cow", "root")

if(metroTextBox1.Text ==" byby")

            {

                Image img = Properties.Resources.Good_Pincode_48px; // Right'as

                metroTextBox1.Icon = img;

            }¥b $ b           否则

            {

                // new wrong()。Show();

                Image img = Properties.Resources.Wrong_Pincode_48px; // Wrong'as

                metroTextBox1.Icon = img;
$


            }

if (metroTextBox1.Text == "byby")
            {
                Image img = Properties.Resources.Good_Pincode_48px; // Right'as
                metroTextBox1.Icon = img;
            }
            else
            {
                // new wrong().Show();
                Image img = Properties.Resources.Wrong_Pincode_48px; // Wrong'as
                metroTextBox1.Icon = img;

            }

推荐答案

嗨GeyBen,

Hi GeyBen,

我担心你使用名为"metroTextBox1"的第三个控件,对吗? winform中的普通文本框没有名为"metroTextBox1 .Icon "的属性。

I'm afraid you used the third control named "metroTextBox1", right? The normal textbox in winform does not have a property named "metroTextBox1.Icon".

您有什么问题?你是什​​么意思if功能不起作用?您编写了哪些事件代码?

What is your problem? What do you mean that the if function don't work? Which event did you write your code?

我建议您使用textChanged事件而不是使用计时器:

I would suggest you use textChanged event for your purpose instead of using a timer:

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text == "byby")
            {
                Image img = Properties.Resources._1; 
                pictureBox1.Image = img;
            }
            else if (textBox1.Text == "cow")
            {
                Image img = Properties.Resources._111;
                pictureBox1.Image = img;
            }
            else if(textBox1.Text == "root")
            {
                Image img = Properties.Resources.Header;
                pictureBox1.Image = img;
            }
        }

问候,

Frankie


这篇关于TextBox.Text =多个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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