|
-
Nov 24th, 2003, 08:41 AM
#1
Thread Starter
Member
Populating a Combobox
Hey all,
I have a rather odd question. I have developed a application and want to fill a combo box with data from a text file. It is complicated as to why I need to do this, let's just say the application is mobile and I don't have access to a database, and can't populate this combo box over the airwaves because the pipe is too small.
Thanks in advance!
-
Nov 24th, 2003, 10:48 AM
#2
So whats the question? Just load what you need from the textfile into an array and bind it to the combo. What code do you have so far?
-
Nov 24th, 2003, 11:00 AM
#3
Frenzied Member
Here's a quick example on how to do it.
1) I created a sample.txt file on my C:
VB Code:
Imports System.IO
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Declare the your File and StreamReader variables
Dim oFile As File
Dim oRead As StreamReader
'Open the text file
oRead = oFile.OpenText("C:\sample.txt")
'Read each line of the file and load it into the combobox
While (oRead.Peek <> -1)
cboText.Items.Add(oRead.ReadLine)
End While
'Close the StreamReader
oRead.Close()
End Sub
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Nov 26th, 2003, 01:01 PM
#4
Thread Starter
Member
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
|