|
-
Feb 18th, 2010, 08:46 AM
#1
Thread Starter
New Member
List box used to open files, advice/help?
Hey, I'm working on a project, basically writing a small application intended to allow the user to open files from a specific directory, edit them without saving (through a RTE), then export the edited content to a word document using bookmarks.
Part of this program I would truly like to add would be a list box displaying the name of files in a specific directory - and for the user to be able to click on each file name in the list box, and for the file contents to display within my RTE. Is this possible? Any advice, help or tutorials would be greatly appreciated.
-
Feb 18th, 2010, 09:09 AM
#2
Re: List box used to open files, advice/help?
I would truly like to add would be a list box displaying the name of files in a specific directory
Check this one: http://www.vbforums.com/showpost.php...79&postcount=3 ...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 18th, 2010, 09:22 AM
#3
Thread Starter
New Member
Re: List box used to open files, advice/help?
Thanks for that That solves part 1 of my problem, part 2, making them act as links to open the files... that's the real stumper.
-
Feb 18th, 2010, 09:27 AM
#4
Re: List box used to open files, advice/help?
What kind of files are they?
-
Feb 18th, 2010, 09:30 AM
#5
Re: List box used to open files, advice/help?
Try something like this:
Code:
RichTextBox1.LoadFile "c:\" & List1.ListIndex
LoadFile will load the file to the Richtextbox (parameter passed is the file location).
If you have populated the listbox from C drive, and List1 contains filenames, then the above code will work.
List1.ListIndex will give the filename of the selected item in Listbox.
I think this will help you... If you have any doubts, please post it...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 18th, 2010, 09:32 AM
#6
Re: List box used to open files, advice/help?
And what happens if the file is not a text file?
-
Feb 18th, 2010, 10:25 AM
#7
Re: List box used to open files, advice/help?
 Originally Posted by Hack
And what happens if the file is not a text file?
Good point. The list of file names will have to be parsed to determine what kind of file it is before any attempt is made by the program to open it and do something with it.
-
Feb 18th, 2010, 10:34 AM
#8
Re: List box used to open files, advice/help?
The link posted in post #2, contains an example Sub for loading files from a folder... It has an optional parameter for the extension of the file. So, the files that are loaded into listbox can be controlled by using the extension. ie. here we will be passing the parameter rtf for the extension. That will make sure that, only the RichTextFormatted files are populated in the listbox.
So, for loading the file in a RichTextBox control(ie. the selected file in ListBox control), use the sample code in post #5 ...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 22nd, 2010, 08:08 PM
#9
Thread Starter
New Member
Re: List box used to open files, advice/help?
Sorry for the delayed reply, internet troubles.
The files I'll primarily be loading will be html format.
I'll attempt your suggestions and see how it goes, thank you for your advice and expertise, I very much appreciate it and hope it works
-
Feb 22nd, 2010, 08:32 PM
#10
Re: List box used to open files, advice/help?
 Originally Posted by taliesan
Sorry for the delayed reply, internet troubles.
The files I'll primarily be loading will be html format.
I'll attempt your suggestions and see how it goes, thank you for your advice and expertise, I very much appreciate it and hope it works 
Be aware that you cannot trust the file extension to determine what the file format really is. You have to examine the file itself to determine whether and how it should be opened and with what. You can always open a file in Binary mode, but after that, you have to determine what to do with it.
-
Feb 24th, 2010, 06:54 AM
#11
Thread Starter
New Member
Re: List box used to open files, advice/help?
Hmn so i've been trying out the suggested solutions today and ran into a problem. I'm using visual studio 5 (as a more familiar environment) and after attempting to display my folders contained files within my list box got the error:
'AddItem' is not a member of 'System.Windows.Forms.ListBox
-
Feb 24th, 2010, 07:23 AM
#12
Re: List box used to open files, advice/help?
That error shows you are not using VB 5 (aka VB 1997), but some form of VB.Net (presumably VB 2005)
Thread moved from 'VB6 and Earlier' forum to 'VB.Net' (VB2002 and later) forum
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|