473,395 Members | 1,474 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,395 software developers and data experts.

Io.FileInfo and comboBox control

Here is what I'm trying to accomplish:

When my form loads it looks at a specific directory for a list of its files
and populates a combo box.
Dim a As New IO.DirectoryInfo("c:\dir")
Dim b As IO.FileInfo() = a.GetFiles()
Dim c As IO.FileInfo

For Each c In b
comboBox1.Items.Add(c)
Next

And that works fine. Then I want to be able to use the entries in the combo
box as string variables to use to open a file for input. The problem is that
the above code populates the combobox with object references(?) so the
comboBox2.SelectedItems doesn't work because the .selectedItems is looking
for a string value. I guess what I'm trying to ask is how can I reference
the items in my combobox as strings so I can assign them to string
variables?

I hope my question isn't confusing because I know I am.

Apr 14 '06 #1
1 1399

R. Harris wrote:
Here is what I'm trying to accomplish:

When my form loads it looks at a specific directory for a list of its files
and populates a combo box.
Dim a As New IO.DirectoryInfo("c:\dir")
Dim b As IO.FileInfo() = a.GetFiles()
Dim c As IO.FileInfo

For Each c In b
comboBox1.Items.Add(c)
Next


If I understand what your after then...

Dim files() as string = System.IO.Directory.GetFiles ("c:\dir")
For Each file As String in files
comboBox1.Items.Add (file)
Next

--
Tom Shelton [MVP]

Apr 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lance | last post by:
I want to expose properties of a class to a user via a PropertyGrid class. Some of the properties are of type System.IO.FileInfo. Ideally, an OpenFileDialog window would appear when the user...
2
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.