Thread: Help With Combo Boxes

  1. #1
    Daniel
    Guest

    Help With Combo Boxes

    Hello I Am Making An MFC Application. I have several combo boxes. I am reading from a file to put text
    inside of them. I am needing to know how to seperate what goes in each box?
    Inside my text file I have:
    400w atx case //needs to go in one combo box
    350w atx case

    Asus Motherboard //needs to go into another combo box
    ECS Motherboard

    Here Is The Code I Use:
    ///////////Code starts here/////////////
    char x; //make big enough to cover file
    CString buffer;
    ifstream file;

    //Open file
    file.open("database.txt", ios::in); //What ever your file is

    //Check for file exist
    //Check for file exist
    if(!file)
    {
    CString facts = "File not found";
    MessageBox(facts,NULL,MB_OK);
    }

    //Read data
    while(!file.eof())
    {
    char x;
    file.get(x);
    if(x=='\n')
    {

    m_drCases.AddString(buffer);
    m_drMother.AddString(buffer);
    //MessageBox(buffer,NULL,MB_OK); //Test buffer
    buffer="";
    }
    else
    buffer = buffer + x;

    }

  2. #2
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Put identfiers int the file
    For example, have your file setup like this:

    [RAM]
    ram type 1
    ram type 2

    [MOTHERBOARD]
    type 1
    type 2

    Then read in some stuff, if it's an identifier, you know what combo box to put stuff in.

    enum comboboxes { motherboard, ram, cases };

    if you read in an identifier, put it in a variable.
    switch (identifier)
    {
    case 1:
    //do stuff
    case 2:
    //do stuff
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create new combo boxes based on items selected in preview combo box
    By RealityFusion in forum Windows Programming
    Replies: 2
    Last Post: 01-10-2007, 09:50 AM
  2. New to Combo Boxes
    By Shenanigans in forum C++ Programming
    Replies: 3
    Last Post: 05-26-2006, 12:01 PM
  3. combo boxes
    By BRITA in forum Windows Programming
    Replies: 1
    Last Post: 03-13-2003, 07:42 AM
  4. Help with Combo Boxes Please
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 07-26-2002, 06:48 PM
  5. Adding Items to Combo Boxes
    By tenthirty in forum Windows Programming
    Replies: 10
    Last Post: 12-21-2001, 02:37 AM