Results 1 to 4 of 4

Thread: Populating a Combobox

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    Cincinnati, OH
    Posts
    44

    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!
    Jim Webster

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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?

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Here's a quick example on how to do it.

    1) I created a sample.txt file on my C:
    VB Code:
    1. Imports System.IO
    2.  
    3. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.      'Declare the your File and StreamReader variables
    5.      Dim oFile As File
    6.      Dim oRead As StreamReader
    7.  
    8.      'Open the text file
    9.      oRead = oFile.OpenText("C:\sample.txt")
    10.  
    11.      'Read each line of the file and load it into the combobox
    12.      While (oRead.Peek <> -1)
    13.          cboText.Items.Add(oRead.ReadLine)
    14.      End While
    15.  
    16.      'Close the StreamReader
    17.      oRead.Close()
    18. End Sub
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    Cincinnati, OH
    Posts
    44
    Thanks Memnoch1207
    Jim Webster

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width