CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2008
    Posts
    86

    Passing file to ComboBox

    Hello All,

    I am new to VB environment. I am using Visual Studio 2005.

    In certain code, I need to add 4000 elements to the ComboBox list.

    Using the command
    ComboBox1.Items.Add()
    seems ridiculous.


    I am thinking of creating EXCEL File, in which I will put all the names in 1 column and call that excel File, when "dropdown" of combo box is clicked.

    Can Anybody tell me, how this will happen??
    Any code related to this? or if this issue has already been discussed then plz give me the link for the same

    If this is not good idea like putting 4000 elements, then can there be any other solution?

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Passing file to ComboBox

    Hi!
    Instead of using an Exce lfile ( which will incur additional overhead ), why not make use of a Text file instead ¿

    Yes, this is possible, but is it really viable ¿ Is there any particular reason why there is so many items ( 4000 ), isn't there a way of separating / organizing these items a bit better ¿

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Passing file to ComboBox

    4000 elements is a bit much for a combo box, could be very difficult to find the item one is looking for. I definitely would not use Excel. A database maybe but Excel no way.

    As for adding the items to a combo you would use the .items.add(), Ideally you would load the data from a text file or database and use the .items.add() in a loop but again 4000 items is a bit much to wade through in a combo.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Passing file to ComboBox

    No, over 25 is a bit much. 4000 is ridiculous. Who would expect a user to read thru half of those, looking for the right choice?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Dec 2008
    Posts
    86

    Re: Passing file to ComboBox

    Thank you for replies.

    Definitely.......I am searching for an alternative to this.

    I am thinking of one but dont know this will work with VB or not......plz let me know.....

    the search engine will work with the combo box.....

    for ex....if user types........DLF........and the same name exists in database.........it will directly move to another window...........but if instead someone types......DL or DF........the search engine will run and search for nearest possible words present in the database. these names will then be displayed to user.

    Is this possible in VB? If yes.....any hint??

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Passing file to ComboBox

    Sure. Start with a BLANK combo. As soon as he types one letter, show the first 25 entries. With the second, the first 25 that match. Etc...

    Doesn't matter if you load the first 25 in the beginning. Just don't try to load and index 4000 at once
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured