CLisrctrl
-
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
-
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
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
-
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 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