Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Data cant be displayed in edit control when we are execute the dialog box After opening the .csv file.

Main Requirement is:

the result which are showing in Dialog box will be changed when we updates the columns which are presented in .csv file at a time (i.e @Run time).

What I have tried:

Am trying to display the strings in given edit boxes with using following sample code:

C++
CStdioFile file;            // access the entire given file
CString cstrLine, Temp;     // Reading the entire row at a time from excel sheet

if (file.Open(L"Data.csv", CFile::shareExclusive | CFile::typeText))    // L ---- 
                                                                      //Multybyte type
{

  while (file.ReadString(cstrLine))
  Temp = cstrLine;
  cstrLine = Temp;         // Reading the last Row every time

  int i = 0;

  for (CString sItem = cstrLine.Tokenize(_T(","), i); i >= 0; sItem = 
                                                       cstrLine.Tokenize(_T(","), i))
  {
	sItem.Trim();  // For trimming extra spaces
	str.Add(sItem);
  }

  m_csName = str.GetAt(0);  //0 means Column 1,s data
  m_csSurName = str.GetAt(1); // 1 means Column 2's data    /* of particular row in 
                                                             Excel sheet */ 
  m_csAge = str.GetAt(2); // 2 means Column 3's data

  UpdateData(FALSE); // Variable 2 Control

  file.Close();
}


But I want following requirement: i.e.,

"the result which are showing in Dialog box (In Edit Boxes) will be changed when we updates the columns which are presented in .csv file at a time (i.e @Run time)."
Posted
Updated 28-Oct-17 7:17am
v4
Comments
Richard MacCutchan 28-Oct-17 4:40am    
Your source data is a .csv file, so once you have read it in and displayed it there is nothing more to do. How does this relate to the Excel data you are referring to?
vpeguda 28-Oct-17 5:30am    
Thats why am asking.... If any reference code is there....... could you please share once......

Thank you
Richard MacCutchan 28-Oct-17 5:42am    
Your question is not clear. You are talking about some Excel file, but the data you are reading comes from a .csv file. Please edit your question and explain exactly what you are trying to do.

1 solution

As I understand your problem is to observe the file for changes and than refresh the data in your app. I see to possible solutions with the simplest that you install a timer which check the last modified time of the file and than reacts.

But more elegant is to observe the file or directory for changes. In the Microsoft article
Obtaining Directory Change Notifications
is not only described but also some sample code how it can be implemented. I also would check the last modified time to avoid excess execution of the update.

It is very important to cleanup all handles at exit!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900