Windows Develop Bookmark and Share   
 index > Windows Forms General > emded a file viewer
 

emded a file viewer

how can i embed a file viewer to a windows form application
user246  Monday, September 21, 2009 11:18 AM
Hello,

Based on my understanding, you want Windows Explorer like control which can list the folders and files on a form. If I misunderstood you, please feel free to correct me.

If my understanding is correct, please take a look at the following sample.
http://www.codeproject.com/KB/cs/tv-lv-basic41.aspx

The left side of the form is a TreeView control while the right side is a ListView. The TreeView control is used to display all the folders. When you click a folder, the ListView will display all the files in that folder.

In the source code, you can see it use DirectoryInfo and FileInfo to retrieve folders and files information from system.

Hope this helps you. If you have any doubt, please feel free to tell me.

Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Wednesday, September 23, 2009 6:31 AM
What type of files (txt file, html file, etc)you want to view in file viewer.
Gaurav Khanna
Khanna Gaurav  Monday, September 21, 2009 11:34 AM

Hi user246,

Do you mean view the content of a file in a form?

If so, we can add a RichTextBox control to show the content. If you only want it to be a viewer, you can set its ReadOnly property to true. You can follow this thread to make it read only:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/49ae9bb4-aa54-4d55-ac91-6e66b99cfc53.
If the viewer only supports text, you can set RichTextBox’s Text property to the content.
If the viewer support rich text, you need to convert the content in the file to rtf text and set RichTextBox’s Rtf property to the rtf text.

You can get more about RichTextBox from:
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx.

Let me know if this helps or not.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Wednesday, September 23, 2009 3:47 AM
Hello,

Based on my understanding, you want Windows Explorer like control which can list the folders and files on a form. If I misunderstood you, please feel free to correct me.

If my understanding is correct, please take a look at the following sample.
http://www.codeproject.com/KB/cs/tv-lv-basic41.aspx

The left side of the form is a TreeView control while the right side is a ListView. The TreeView control is used to display all the folders. When you click a folder, the ListView will display all the files in that folder.

In the source code, you can see it use DirectoryInfo and FileInfo to retrieve folders and files information from system.

Hope this helps you. If you have any doubt, please feel free to tell me.

Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Wednesday, September 23, 2009 6:31 AM

You can use google to search for other answers

Custom Search

More Threads

• TabControl tab size
• Flowlayoutpanel resize inside a panel
• Help - Partitions
• DDEML in Visual Basic 6
• Internet explorer add on issue
• Is this a bug of RichTextBox(VS2005)?
• Exception from HRESULT: 0x800A01C9
• How do you catch the delete event on a datagrid
• Print One Windows Form Control
• How to add non editable line numbers in richtextbox??