首页 新闻 会员 周边

C#的textBox的loadFilede 的错误怎么解决

0
悬赏园豆:15 [已解决问题] 解决于 2017-03-07 13:09

        private void ReadFiles(string path)
        {
            try
            {
                Stream stream = new FileStream(path,FileMode.Open);
                FileInfo fileinfo = new FileInfo(path);
                string fileExtension = fileinfo.Extension.ToUpper();

                if (fileExtension.Equals(".RTF"))
                {
                    this.textBox1.LoadFile(stream, RichTextBoxStreamType.RichText);

(c:\users\ibm_admin\documents\visual studio 2010\Projects\CS_TEST_APP_002\Form1.cs(230,35): error CS1061: 'System.Windows.Forms.TextBox' does not contain a definition for 'LoadFile' and no extension method 'LoadFile' accepting a first argument of type 'System.Windows.Forms.TextBox' could be found (are you missing a using directive or an assembly reference?))(这个错误是怎么回事啊)
                }
                else
                {
                    this.textBox1.LoadFile(stream, RichTextBoxStreamType.PlainText);
                }
                    

                stream.Close();
            }
            catch { return; }
        }

静静流的主页 静静流 | 初学一级 | 园豆:11
提问于:2017-01-16 16:53
< >
分享
最佳答案
0

微软提供的Textbox类是没有这方法的,如果你在其他地方看到,可能是其他人进行了自己的扩展。所以你应该拷贝其他人的对应的扩展类。并引用。

收获园豆:15
心雨纷扬 | 菜鸟二级 |园豆:309 | 2017-01-18 09:38
其他回答(1)
0

TextBox有这个方法?

Daniel Cai | 园豆:10424 (专家六级) | 2017-01-16 17:09

没有,但是在做treeview是他是个自动调用,我也不知道啊


支持(0) 反对(0) 静静流 | 园豆:11 (初学一级) | 2017-01-16 17:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册