简体   繁体   中英

Message box to include textbox.text

I want to show the textbox text in my message box keep getting error.

MessageBox.Show(textBox1.text + "Saved As PDF");

and the error is

Error   1   'System.Windows.Forms.TextBox' does not contain a definition for
   'text' and no extension method 'text' accepting a first argument of type
   'System.Windows.Forms.TextBox' could be found (are you missing a using 
   directive or an assembly reference?) 
   R:\Engineer\Russell Saari\CONFIGURATOR MODELS\MLD028 Userform (C# Coding)\WindowsFormsApplication2\MLD028D Actuator Form Complete.cs 118 38 WindowsFormsApplication

Properties usually start with a capital letter.

Try

MessageBox.Show(textBox1.Text + "Saved As PDF");

(note the T in .Text is capitalized)

You don't say what the error is, but to start, let's make your code compile. Text should be capitalized.

MessageBox.Show(textBox1.Text + "Saved As PDF");

private void btnRemove_Click(object sender, EventArgs e) { string firstVal = textBox1.SelectedText;

        if (listBox1.Text == String.Empty)
        {
            MessageBox.Show("Please select a Name");
        }
        else
        {
            if (MessageBox.Show("Do you want to remove this name", +firstVal, "Remove Name" 
             , MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                listBox2.Items.Add(listBox1.Text);
                listBox1.Items.Remove(listBox1.Text);
            }



        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM