Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CLisrctrl

CLisrctrl

Scheduled Pinned Locked Moved C / C++ / MFC
helpios
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Girish601
    wrote on last edited by
    #1

    Hi friends, I develop one application. I retrieve values from variable and add it to text file. when I click Add button, records are added into file. I also display data from file in List control.But one problem is occur. when I add record and click on show button, first record display two times. I close file , and again execute application and add new record, and click on show button now earlier record display one time and new entry is shown 2 times. sample code on Display button, with the help of this code I display record in list control fstream file("D:\\Mfctut\\kdr.txt",ios::out |ios::in ); do { file.read((char*)(&kdr),sizeof(kdr)); int nIndex = m_Listvw.InsertItem(0,""); m_Listvw.SetItemText(nIndex,0,kdr.name); m_Listvw.SetItemText(nIndex,1,kdr.address); }while(file.eof()!=TRUE); kindly give me a reply. Regards kedar Girish Software Developer

    I D 2 Replies Last reply
    0
    • G Girish601

      Hi friends, I develop one application. I retrieve values from variable and add it to text file. when I click Add button, records are added into file. I also display data from file in List control.But one problem is occur. when I add record and click on show button, first record display two times. I close file , and again execute application and add new record, and click on show button now earlier record display one time and new entry is shown 2 times. sample code on Display button, with the help of this code I display record in list control fstream file("D:\\Mfctut\\kdr.txt",ios::out |ios::in ); do { file.read((char*)(&kdr),sizeof(kdr)); int nIndex = m_Listvw.InsertItem(0,""); m_Listvw.SetItemText(nIndex,0,kdr.name); m_Listvw.SetItemText(nIndex,1,kdr.address); }while(file.eof()!=TRUE); kindly give me a reply. Regards kedar Girish Software Developer

      I Offline
      I Offline
      includeh10
      wrote on last edited by
      #2

      can not find different code for "earlier record" and "new entry". check if "add new" function is called for twice, try add a flag to ensue it is called for only once: MyClass::ClickButton() { //the bool value is initialized as 0 before in constructor. b_AddNew=1; AddNewFunction(); } MyClass::AddNewFunction() { if(b_AddNew==0) return; b_AddNew=0; do { //your code }while(...); }


      A special image tool for Windows C++ programmers, don't miss it! The world unique Software Label Maker is waiting for you and me ... A nice hyper tool for optimizing your Microsoft html-help contents. -- modified at 13:00 Saturday 1st April, 2006

      1 Reply Last reply
      0
      • G Girish601

        Hi friends, I develop one application. I retrieve values from variable and add it to text file. when I click Add button, records are added into file. I also display data from file in List control.But one problem is occur. when I add record and click on show button, first record display two times. I close file , and again execute application and add new record, and click on show button now earlier record display one time and new entry is shown 2 times. sample code on Display button, with the help of this code I display record in list control fstream file("D:\\Mfctut\\kdr.txt",ios::out |ios::in ); do { file.read((char*)(&kdr),sizeof(kdr)); int nIndex = m_Listvw.InsertItem(0,""); m_Listvw.SetItemText(nIndex,0,kdr.name); m_Listvw.SetItemText(nIndex,1,kdr.address); }while(file.eof()!=TRUE); kindly give me a reply. Regards kedar Girish Software Developer

        D Offline
        D Offline
        Dr Kuulun
        wrote on last edited by
        #3

        I can't find what is wrong. But you should place the while-statement at the beginning of the loop. Your loop will show wrong data or crashes if you open an empty file. Dr-Kuulun

        G 1 Reply Last reply
        0
        • D Dr Kuulun

          I can't find what is wrong. But you should place the while-statement at the beginning of the loop. Your loop will show wrong data or crashes if you open an empty file. Dr-Kuulun

          G Offline
          G Offline
          Girish601
          wrote on last edited by
          #4

          hi Dr-Kuulun, I received your response. I will try to solve out problem. Thanks for give me a reply. Regards kedar Girish Software Developer

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups