none
TextBox.Text = Multiple words RRS feed

  • Question

  • 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:

    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;
                }
                else
                {
                    // new wrong().Show();
                    Image img = Properties.Resources.Wrong_Pincode_48px; // Wrong'as
                    metroTextBox1.Icon = img;

                }

    • Moved by CoolDadTx Thursday, May 17, 2018 3:22 PM Winforms related
    • Moved by Stanly Fan Thursday, May 24, 2018 2:11 AM 3rd Resources
    Thursday, May 17, 2018 12:36 PM

All replies

  • Hi GeyBen,

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

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

    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;
                }
            }

    Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 18, 2018 1:47 AM