1
我已經創建了一個使用列表控件的網格函數。列表中有兩列。數據和名稱。如何在Visual Studio中的MFC中的ListControl中顯示選定的文件名?
用戶應該選擇一個文件;並且文件內的數據應顯示在第一列「數據」中,文件名應顯示在第二列「名稱」中。 我已經寫了代碼,但沒有什麼是出現在列表
CFileFind finder;
bool bFound;
CString filename = "C:\\ Location\\*.txt";
bFound = finder.FindFile(filename);
if(bFound)
{
while(bFound)
{
bFound = finder.FindNextFile();
if(bFound)
{
m_List.AddString(finder.GetFileName()); //This is where the actual data is added
}
}
CStdioFile files;
CFileException exp;
CString strLine;
if (files.Open(filename, CFile::modeRead, &exp))
{
while(files.ReadString(strLine)){}
}
}
void CuserspecificationDlg::InsertItems()
{
HWND hWnd = ::GetDlgItem(m_hWnd, IDC_LIST1);
// Set the LVCOLUMN structure with the required
// column information
..
..
SetCell(hWnd,out,1,1); // where out is the Cstring variable for edit control
}
什麼可以是錯誤的?
我正在使用ListControl,而不是Listbox。 – Nabeel 2012-07-31 10:16:45