RichTextBox 顯示圖片和word的代碼
更新時間:2013年02月18日 16:18:26 作者:
RichTextBox 顯示圖片和word的代碼,需要的朋友可以參考一下
顯示圖像:
復制代碼 代碼如下:
Image img = Image.FromFile( @"E:\image\bottle\2006122013203825344.jpg" );
Clipboard.SetDataObject( img );
RichTextBox.Paste( DataFormats.GetFormat( DataFormats.Bitmap ) );
顯示word
string filename = @"d:\隨筆.doc";
//C#讀取word文件之實例化COM
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object fileobj = filename;
object nullobj = System.Reflection.Missing.Value; //打開指定文件(不同版本的COM參數(shù)個數(shù)有差異,一般而言除第一個外都用nullobj就行了)
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open( ref fileobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj ); //取得doc文件中的文本
ResponseFormsMediator.RemindersRichTextBox.Text += doc.Content.Text; //C#讀取word文件之關閉文件
doc.Close( ref nullobj, ref nullobj, ref nullobj ); //C#讀取word文件之關閉COM wordApp.Quit( ref nullobj, ref nullobj, ref nullobj );
相關文章
通過Windows Visual Studio遠程調(diào)試WSL2中的.NET Core Linux應用程序的方法
這篇文章主要介紹了通過Windows Visual Studio遠程調(diào)試WSL2中的.NET Core Linux應用程序的方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-07-07ASP.NET MVC用存儲過程批量添加修改數(shù)據(jù)操作
這篇文章主要介紹了ASP.NET MVC用存儲過程批量添加修改數(shù)據(jù)的方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-02-02asp.net(C#)防sql注入組件的實現(xiàn)代碼
經(jīng)常要寫一些.net的程序,對于數(shù)據(jù)庫的防注入要求要比較高。這時我從網(wǎng)上搜了一些代碼。查看了一下主要是通過HTTPModel來進行對客戶端轉(zhuǎn)過來的數(shù)據(jù)進行處理。2009-12-12Asp.Net中的數(shù)據(jù)源概述與配置及實例代碼
數(shù)據(jù)綁定分為數(shù)據(jù)源和數(shù)據(jù)綁定控件兩部分,數(shù)據(jù)綁定控件通過數(shù)據(jù)源來獲得數(shù)據(jù);接下來本文將分別介紹下數(shù)據(jù)源/數(shù)據(jù)綁定控件/ObjectDataSource2013-02-02asp.net下出現(xiàn)其中的組件“訪問被拒絕”的解決方法
asp.net下出現(xiàn)其中的組件“訪問被拒絕”的解決方法...2007-04-04淺談誰都能看懂的單點登錄(SSO)實現(xiàn)方式(附源碼)
這篇文章主要介紹了淺談誰都能看懂的單點登錄(SSO)實現(xiàn)方式(附源碼),具有一定的參考價值,有需要的可以了解一下。2016-12-12