如何在Visual Studio中的MFC中的ListControl中显示所选文件名
How to display the selected file name in the ListControl in MFC in Visual Studio?
我使用列表控件创建了一个网格函数。列表中有两列。数据和名称。
用户应选择一个文件;文件内的数据应显示在第一列"data"中,文件名应显示在第二列"name"中。我已经写了一个代码,但列表中没有出现任何内容
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
}
可能是什么错误?
请参阅此处的列表框使用教程。您可以定义一个CListBox类型的成员变量,该变量通过控件向导映射到您的列表框。
相关文章:
- 从数据库实时显示QT c++中的数据
- 当简单捕获中的标识符显示为参数的声明符 ID 时,没有编译器诊断
- 链表中的显示功能无法正常工作
- 显示数组中的学生 ID 和最高分
- 访问和打印元组中的数据,并使用 C++14 使用模板函数显示数据
- 在链表中的第 n 位插入显示分割错误
- 将信息输入到下面显示的结构向量中的正确语法/格式是什么
- 为什么我的 cout 在输出中没有显示字符串?
- Windows 资源管理器中的图标在使用 resource.rc 时显示 2 个不同的图标
- 实例化模板时,我是否必须显式显示参数包中的类型?
- C++ 我的开关格式中的循环不允许我显示菜单选项或接受输入?
- SFML 中的字体.信息不显示在屏幕上.显示的不是信息,而是点
- 在C++中的SDL2窗口上显示.bmp时出现问题
- Qt表查看单元格中的显示图像并在单击时获取路径
- mpi_scatterv中的显示参数是什么?
- 模板在翻译单元中的显示方式
- 体系结构x86_64的未定义符号-头文件中的显示功能
- 对于多线程应用程序中的显示任务,原子锁或互斥锁是必须的吗
- 使用c++获取当前运行进程中的X显示变量
- 可以将OpenGL用于我的QGraphicsItems加快在QGraphicsView中的显示速度