473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Populate combobox from contents of folder

133 100+
hi guys,

I would like to populate a combobox list with the contents of a folder which contains text files , which will later be opened.

Thanks in advanced for any help :)

Gobble.
Feb 18 '08 #1
4 5691
debasisdas
8,127 Expert 4TB
Kindly post what you have tried.

NOTE: Try to use Filelistbox for the purpose.
Feb 18 '08 #2
gobblegob
133 100+
Kindly post what you have tried.

NOTE: Try to use Filelistbox for the purpose.

Well i couldnt work how to add all folder contents to a combobox, But i did workout another way to do what i need.


Expand|Select|Wrap|Line Numbers
  1.     Dim combolist As String
  2.     Combo1.Clear
  3.     Open "c:\list\listpop.txt" For Input As #1
  4.     Do While EOF(1) = False
  5.     Line Input #1, combolist
  6.     Combo1.AddItem combolist
  7.     Loop
  8.   Close #1
Feb 18 '08 #3
debasisdas
8,127 Expert 4TB
Does the text file contains the list of files in the folder.
Feb 18 '08 #4
jamesd0142
469 256MB
This is vb.net code:

Expand|Select|Wrap|Line Numbers
  1.  Private Sub load()
  2.         ComboBox1.Items.Clear()
  3.         ComboBox1.Text = Nothing
  4.         'Dim startpath As String = "C:\a"
  5.         Dim myfolder As DirectoryInfo = New DirectoryInfo(startpath & "\")
  6.  
  7.         'get all file in folder with .txt extension
  8.         Dim strFiles() As FileInfo = myfolder.GetFiles("*.txt")
  9.  
  10.         'for each file add to combobox
  11.         For Each myItem As FileInfo In strFiles
  12.             ComboBox1.Items.Add(myItem)
  13.         Next
  14.     End Sub
  15.  
Feb 18 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Mark | last post by:
How can I populate a listbox with a list of the filenames in a certain folder? Can a query retrieve the filenames from a folder? Thanks! Mark
3
by: MS | last post by:
I would like to be able to examine a folder, and populate a List Box or Combo Box with the files that are in it. How would you go about doing this? The reason is that I would like the user to...
4
by: Marc Jennings | last post by:
Hi there, I'm new to C#, and I have a small problem. I have created a new DataSet using the code below, and I would like to be able to populat a drop-down list with the results of the "name"...
4
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be...
0
by: masterej | last post by:
I'm trying to populate a ComboBox (dropdown style) with strings of text from an ArrayList. The ComboBox is actually being populated with the correct items, however, they appear only as blank...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
4
by: polaris431 | last post by:
All the examples I've seen showing how to populate a combobox using the DataSource property and an ArrayList show the ArrayList object containing objects with at least two properties. I want to...
1
by: freekedoutfish | last post by:
Hi. New member here Im sat at work, pounding my head off the desk because this tiny bit of simple code refuses to work. The sub is intended to pull data from the "companyname" column in the...
1
by: neehakale | last post by:
Pls tel me how to pass values to combobox in c# winforms.i simply want to pass the values not form database and all i want to pass values to combobox form file and after clicking that value it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.