2011-09-06 54 views
-1

我想在我的消息框中显示文本框文本不断出现错误。消息框中包含textbox.text

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

,误差

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 
+0

什么是错误? – ChrisF

+0

查看Brandon的回答。你应该在你的问题中包含这个。使用[编辑](http://stackoverflow.com/posts/7325662/edit)链接。 – ChrisF

回答

9

属性一般用大写字母开头。

尝试

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

(注意.TextT是大写)

+0

+1打我吧 –

+0

试过同样的错误? –

+2

@Russell,我几乎可以肯定你在同一行代码中没有得到相同的错误。你发布的错误基本上说TextBox没有一个名为'text'的属性。这是正确的,它有一个名为'Text'的属性。你记得重建你的项目吗?你能否在你的问题中添加新的错误信息? (如ChrisF所说,使用您的问题下面的'编辑'链接)。 – Brandon

4

你不说是什么错误,但首先,让我们使你的代码编译。 Text应该大写。

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