CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    12

    writing ini file data to gui text/list box

    Hi Guys,

    I am creating a program which needs to get all the info from my gui and store it in an ini file. Then when the program is started again, i need that info to be loaded back up into the gui from the ini file.

    So far all of my info from my gui is saved in my ini file with no problem whena button is pressed. But my problem is now adding the data back into the gui from the ini file. I have tried to use readSection but it doesnt seem to work.

    Here is the data to write the info from the gui to the ini file

    Code:
      IniFile ^iniFile = gcnew IniFile("C:\\files\\axe.ini");
                             iniFile->writeSection("Options", "Startfile", "D:\\Student\\_Files\\__Script.txt");
                             //FileStream ^fs = gcnew FileStream("D:\\Student\\_Files\\Data.ini", FileMode::Truncate);
                             IniFile ^iniFile1 = gcnew IniFile("D:\\Student\\_Files\\Data.ini");
                             
                             TextBoxesData();
    
    
    
                           //sets up the code to count from the first variable to the last in the listbox
                           for(int i=0;i<listBox1->Items->Count;i++)
                           {
                               IniFile ^iniFile1 = gcnew IniFile("D:\\Student\\_Files\\Data.ini");
                            //int count = listBox1::SendMessage(m_hWP_List,LB_GETCOUNT , 0, 0);
                            
                            iniFile1->writeSection("Last Variables","Total_Number_of_Variables","" +listBox1->Items->Count);
                           
                                                    String ^str = listBox1->Items[i]->ToString();
                            
                            
                            iniFile1->writeSection("Last Variables", " listBox1_Items"+i.ToString() ,str);
    the above works perfectly well, but now, how do i get this info to go back into the listbox1 in this case once the program is started again.

    i have tried the following exapmle which compiles, but it doesnt do anything

    Code:
                                                      //FileStream ^fs = gcnew FileStream("D:\\Student\\_Files\\Data.ini", FileMode::Truncate);
                             IniFile ^iniFile1 = gcnew IniFile("D:\\Student\\_Files\\Data.ini");
                             
                             TextBoxesData();
    
    
    
                           //sets up the code to count from the first variable to the last in the listbox
                           
                           
                               IniFile ^iniFile1 = gcnew IniFile("D:\\Student\\_Files\\Data.ini");
                            
                            
                            iniFile1->readSection("Last Variables","Total_Number_of_Variables");
    but it doesnt do what i want it to.

  2. #2
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: writing ini file data to gui text/list box

    you've asked this question already, haven't you?

    http://www.codeguru.com/forum/showth...hlight=IniFile
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  3. #3
    Join Date
    Jun 2009
    Posts
    12

    Re: writing ini file data to gui text/list box

    Na, that was to write listbox items INTO an ini file, I need to now get those items from the ini file and put them back into the listbox once my program is restarted.

    As i said, I know I have to use readSection instead of writeSection, but after that I am totally stuck.

    Any suggestions would be great, i do not need the whole code, i just need guidance

    Thanks

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