| | | | Browse by category |
Article ID: 93
Last updated: 22 Jun, 2018
Problem
How can I read data from a text file in tab-delimited format?
Cause
Action
The PasteTextFromBuffer() can paste the text values from a buffer with tab-delimited data into the grid. The following example demonstrates how you can load data from a text file:
void CGridSampleView::OnImportTextFile() { |
|||
// pop-up file-open dlg to ask for location CfileDialog dlgFile( |
|||
TRUE, _T(".txt"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Text Files (*.txt)|*.txt|All Files (*.*)|*.*||")); |
|||
if (dlgFile.DoModal() == IDCANCEL) | |||
return; | |||
CFile textFile;
if (!textFile.Open(dlgFile.GetFileName(), CFile::modeRead)) |
|||
TCHAR sz[255]; wsprintf(sz, "File %s could not be opened!", dlgFile.GetFileName()); AfxMessageBox(sz); return; |
|||
}
LPTSTR pszBuffer; PasteTextFromBuffer(pszBuffer, dwSize, CGXRange(0,1)); delete pszBuffer; |
|||
} |
This article was:
Helpful |
Not helpful
Report an issue
Article ID: 93
Last updated: 22 Jun, 2018
Revision: 3
Views: 1955
Posted: 12 Jan, 2001 by
Meltreger B.
Updated: 22 Jun, 2018 by
Meltreger B.
Others in this category
Powered by KBPublisher (Knowledge base software)