|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Io.FileInfo and comboBox controlWhen 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. R. Harris wrote:
> Here is what I'm trying to accomplish: If I understand what your after then...> > 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 > 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]
How to release a free source code?
Dynamically open forms, reports or call functions Copywriting or protecting your program Database update problems. How to convert a regular VB app into a service to run on a Windows 2003 server? Threading a Create Dataset method is there a way to do this Crypto Question How to show a form of c# in VB.Net from ? String Tokenizing - Help! |
|||||||||||||||||||||||