开发者

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.Text开发者_运维百科Box' 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);
            }
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜