我想在单独的窗口中显示列表项。但是,当窗口打开时,它不会显示列表。我可以单击列表项,但看不到它。如果我单击数据,它会一一显示。此外,当我向下滚动列表时,它也会显示数据。
我已经厌倦了
m_bList_index.UpdateData(FALSE);
m_bList_index.UpdateWindow();
m_bList.UpdateData(FALSE);
m_bList.UpdateWindow();
在DisplayList()函数的最后,但这不能解决问题。下面是我要编辑的代码。
CListBox m_bList_index;
CMyListBox m_bList;
BOOL CBatch::OnInitDialog()
{
CDialog::OnInitDialog();
m_status.Empty();
m_bIndex.Empty();
m_elapsed_time.Empty();
m_estimated_time.Empty();
CenterWindow();
m_bList.CreateColumn();
DisplayList();
return TRUE;
// return TRUE unless you set the focus to a control
}
void CBatch::DisplayList()
{
unsigned int size;
m_bList_title.ResetContent();
m_bList_title.SetHorizontalExtent(2000);
m_bList_title.InsertString(0, theApp.m_pFieldBTitleStr);
theApp.bCheckList->SetSortingType(theApp.checkList->GetSortingType());
theApp.bCheckList->Sort();
size = theApp.bCheckList->GetSize();
m_bList_index.SetRedraw(FALSE);
m_bList_index.ResetContent();
m_bList_index.SetHorizontalExtent(2000);
m_bList.SetRedraw(FALSE);
m_bList.DeleteAllItems();
m_bList.SetHorizontalExtent(2000);
char ColumnName[256];
char strColumnValue[256];
double fColumnValue;
for (unsigned int i = 0; i < size; i++)
{
char buffer[255];
int index = 0;
if(m_bList.m_SerialNo)
{
sprintf(buffer,"%d",i+1);
m_bList.InsertItem(i, buffer,0);
index = 0;
}
else
{
theApp.bCheckList->m_checkArray[i]->get((CV_CHECK_FIELD)(m_bList.ListColumns[0]),buffer);
m_bList.InsertItem(i, buffer,0);
index = 1;
}
for(; index < m_bList.NoofColumns; index++)
{
LV_COLUMN rightjust;
rightjust.mask = LVCF_FMT;
rightjust.fmt = LVCFMT_RIGHT;
m_bList.SetColumn(index+m_bList.m_SerialNo,&rightjust);
memset(buffer,0x0,256);
theApp.bCheckList->m_checkArray[i]->get((CV_CHECK_FIELD)(m_bList.ListColumns[index]),buffer);
if ( (m_bList.ListColumns[index] == CV_CHECK_FIELD_FILELOCATION) ||
(m_bList.ListColumns[index] == CV_CHECK_FIELD_POSTED_DATE) ||
(m_bList.ListColumns[index] == CV_CHECK_FIELD_STATUS))
strcpy(buffer, buffer);
}
m_bList.SetItemText(i,index+m_bList.m_SerialNo,buffer);
}
}
m_bList.SetSel(0, TRUE);
m_bList.SetRedraw(TRUE);
m_bList_index.SetRedraw(TRUE);
UpdateData(FALSE);
}