关于CListCtrl重复插件的问题

hellen_99010 2015-08-30 12:50:07
搞了好久,实在找不到具体的原因了。只能上来求助于大家了。
具体情况是这样的,我在查询的时候,把数据加到列表里了,再次点击查询的时候,我想先清掉原来列表的数据。再重新插件新的数据。 用了BOOL DeleteAllItems( );这个方法就是删除不了。有人知道的话,帮我解决下呗。不胜感激

void DetectionMgrDlg::LoadReprotListByDate() {
CString curDateTime = m_tDateTime.Format(_T("%Y/%m/%d"));
int year = m_tDateTime.GetYear();
int month = m_tDateTime.GetMonth();
int day = m_tDateTime.GetDay();

m_testReportDao.GetTestReportList(year,month,day);
int nCount = m_testReportDao.m_TestReportList.GetSize();
//允许导出报表
if(nCount>0) {
m_cExportReportBtn.EnableWindow(true);

}

m_cReportList.DeleteAllItems();

for (int i=nCount-1;i>=0;i--) {
CTestReport& testReport = m_testReportDao.m_TestReportList.GetAt(i);

int curItem = m_cReportList.InsertItem(0,"");
CString rowIndex;
CString curDateTime = testReport.GetTestTime();
CString productNo = testReport.GetProductNo();

CString testThickness;
testThickness.Format("%.3lf",testReport.GetTestThickness());

CString sBatteryThickness;
sBatteryThickness.Format("%.3lf",testReport.GetBatteryThickness());

CString sErrandUp;
sErrandUp.Format("%.3lf",testReport.GetBatteryErrandUp());

CString sErrandDown;
sErrandDown.Format("%.3lf",testReport.GetBatteryErrandDown());

CString sResult = testReport.GetTestResult();

rowIndex.Format("%d",testReport.GetId());
m_cReportList.SetItem(curItem,0,LVIF_TEXT,rowIndex,NULL,0,0,0);
m_cReportList.SetItem(curItem,1,LVIF_TEXT,curDateTime,NULL,0,0,0);
m_cReportList.SetItem(curItem,2,LVIF_TEXT,productNo,NULL,0,0,0);
//m_cReportList.SetItem(curItem,3,LVIF_TEXT,curDateTime,NULL,0,0,0);
m_cReportList.SetItem(curItem,4,LVIF_TEXT,testThickness,NULL,0,0,0);
m_cReportList.SetItem(curItem,5,LVIF_TEXT,sBatteryThickness,NULL,0,0,0);
m_cReportList.SetItem(curItem,6,LVIF_TEXT,sErrandUp,NULL,0,0,0);
m_cReportList.SetItem(curItem,7,LVIF_TEXT,sErrandDown,NULL,0,0,0);
m_cReportList.SetItem(curItem,8,LVIF_TEXT,sResult,NULL,0,0,0);
CTestReport testReport2;
testReport = testReport2;
}
}
...全文
79 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
大鱼> 2015-08-30
  • 打赏
  • 举报
回复
我大致看了一下你的代码,如果再次查询响应这个函数应该没什么问题。
大鱼> 2015-08-30
  • 打赏
  • 举报
回复
你的意思是你惦记查询就会响应这个函数对吗? 你必须在你响应这个函数的时候也就是再次插入数据到ListControl中之前响应DeleteAllItem()函数。
hellen_99010 2015-08-30
  • 打赏
  • 举报
回复
引用 4 楼 schlafenhamster 的回复:
m_cReportList.DeleteAllItems(); 与 m_testReportDao.m_TestReportList 什么关系?
m_TestReportList是我查询出来的列表数据 解决了,问题就是出在这里。我用了一个全局的CArray变量造成的。
schlafenhamster 2015-08-30
  • 打赏
  • 举报
回复
m_cReportList.DeleteAllItems(); 与 m_testReportDao.m_TestReportList 什么关系?
hellen_99010 2015-08-30
  • 打赏
  • 举报
回复
引用 1 楼 qq_17486399 的回复:
你的意思是你惦记查询就会响应这个函数对吗? 你必须在你响应这个函数的时候也就是再次插入数据到ListControl中之前响应DeleteAllItem()函数。
是的,我点击查询就响应这函数。在加载数据到列表前先把列表的数据先删除。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧