列代码:
void CEx_StudentView::OnStuinfoAdd() { // TODO: Add your command handler code here CStuInfoDlg dlg; if (dlg.DoModal() != IDOK) return;// 复制照片文件 CString strFileTO; strFileTO.Format("c://%s.bmp", dlg.m_strNo); if (!dlg.m_strPhotoFilePath.IsEmpty()) DoCopyFile(strFileTO, dlg.m_strPhotoFilePath); // 添加列表项 CListCtrl&; m_ListCtrl = GetListCtrl(); int nItem = m_ListCtrl.GetItemCount(); CString strSex("男"); 5
VC 程序设计-实验指导 if (dlg.m_bMale) strSex = "女"; m_ListCtrl.InsertItem( nItem, dlg.m_strNo ); m_ListCtrl.SetItemText( nItem, 1, dlg.m_strName ); m_ListCtrl.SetItemText( nItem, 2, strSex ); m_ListCtrl.SetItemText( nItem, 3, dlg.m_tBirth.Format("%Y-%m-%d") ); m_ListCtrl.SetItemText( nItem, 4, dlg.m_strSpecial); }
③ 编译运行并测试。 6.实现打印和打印预览 . ① 为 CEx_StudentView 类添加一个成员变量 m_strContents,类型为 CStringArray。用来保存读取列表 项的数据。 ② 为 CEx_StudentView 类添加一个成员函数 ReadListViewData, 用于读取列表项的数据, 其代码如下:
void CEx_StudentView::ReadListViewData(