我想在我的 ListCtrl 中插入一些项目。这是我的代码。我似乎无法在程序中发现错误。不幸的是,并非所有项目都显示在列表中,我不知道为什么会这样。请帮我。
LVITEM lItem;
lItem.mask=LVIF_TEXT;
lItem.iItem = 1 + (nColNum - 1) * 3;
lItem.iSubItem=0;
lItem.pszText = W2T(L"");
pDlgSportNews->m_List.InsertItem( 1 + (nColNum-1 ) * 3 , lItem.pszText);
WCHAR szzText[MAX_PATH];
lItem.iItem = 1 + (nColNum - 1) * 3;
lItem.iSubItem = 1;
lItem.pszText = W2T(m_arData[nColNum - 1].szGameName);
pDlgSportNews->m_List.SetItemText(1 + (nColNum - 1) * 3 , 1 , lItem.pszText);
lItem.mask=LVIF_TEXT;
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 0;
lItem.pszText = W2T(m_arData[nColNum - 1].szGameTime);
pDlgSportNews->m_List.InsertItem(2 + + (nColNum - 1) * 3 , lItem.pszText);
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 1;
lItem.pszText = W2T(m_arData[nColNum - 1].szA_Team);
pDlgSportNews->m_List.SetItemText( 2 + (nColNum - 1) * 3 , 1 , lItem.pszText);
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 2;
if (m_arData[nColNum - 1].bFT_HDP)
{
swprintf(szzText , L"%s %s" , m_arData[nColNum - 1].szFT_HDP , m_arData[nColNum - 1].szFT_A_HDP);
lItem.pszText = W2T(szzText);
}
else
lItem.pszText = W2T(m_arData[nColNum - 1].szFT_A_HDP);
pDlgSportNews->m_List.SetItemText( 2 + (nColNum - 1) * 3 , 2 , lItem.pszText);
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 3;
swprintf(szzText , L"%s %s" , m_arData[nColNum - 1].szFT_UO , m_arData[nColNum - 1].szFT_A_UO);
lItem.pszText=W2T(szzText);
pDlgSportNews->m_List.SetItemText( 2 + (nColNum - 1) * 3 , 3 , lItem.pszText);
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 4;
lItem.pszText = W2T(m_arData[nColNum - 1].szFT_S_Odd);
pDlgSportNews->m_List.SetItemText( 2 + (nColNum - 1) * 3 , 4 , lItem.pszText);
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 5;
if (m_arData[nColNum - 1].bHT_HDP)
{
swprintf(szzText , L"%s %s" , m_arData[nColNum - 1].szHT_HDP , m_arData[nColNum - 1].szHT_A_HDP);
lItem.pszText=W2T(szzText);
}
else
lItem.pszText = W2T(m_arData[nColNum - 1].szHT_A_HDP);
pDlgSportNews->m_List.SetItemText( 2 + (nColNum - 1) * 3 , 5 , lItem.pszText);
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 6;
swprintf(szzText , L"%s %s" , m_arData[nColNum - 1].szHT_UO , m_arData[nColNum - 1].szHT_A_UO);
lItem.pszText=W2T(szzText);
pDlgSportNews->m_List.SetItemText( 2 + (nColNum - 1) * 3 , 6 , lItem.pszText);
lItem.iItem = 2 + (nColNum - 1) * 3;
lItem.iSubItem = 7;
lItem.pszText = W2T(m_arData[nColNum - 1].szHT_S_Odd);
pDlgSportNews->m_List.SetItemText( 2 + (nColNum - 1) * 3 , 7 , lItem.pszText);
lItem.pszText = W2T(L" ");
pDlgSportNews->m_List.InsertItem( 3 + (nColNum-1 ) * 3 , lItem.pszText);
lItem.iItem = 3 + (nColNum - 1) * 3;
lItem.iSubItem = 1;
lItem.pszText = W2T(m_arData[nColNum - 1].szB_Team);
pDlgSportNews->m_List.SetItemText( 3 + (nColNum - 1) * 3 , 1 , lItem.pszText);
lItem.iItem = 3 + (nColNum - 1) * 3;
lItem.iSubItem = 2;
if (!m_arData[nColNum - 1].bFT_HDP)
{
swprintf(szzText , L"%s %s" , m_arData[nColNum - 1].szFT_HDP , m_arData[nColNum - 1].szFT_B_HDP);
lItem.pszText=W2T(szzText);
}
else
lItem.pszText = W2T(m_arData[nColNum - 1].szFT_A_HDP);
pDlgSportNews->m_List.SetItemText( 3 + (nColNum - 1) * 3 , 2 , lItem.pszText);
lItem.iItem = 3 + (nColNum - 1) * 3;
lItem.iSubItem = 3;
lItem.pszText = W2T(m_arData[nColNum - 1].szFT_B_UO);
pDlgSportNews->m_List.SetItemText( 3 + (nColNum - 1) * 3 , 3 , lItem.pszText);
lItem.iItem = 3 + (nColNum - 1) * 3;
lItem.iSubItem = 4;
lItem.pszText = W2T(m_arData[nColNum - 1].szFT_D_Odd);
pDlgSportNews->m_List.SetItemText( 3 + (nColNum - 1) * 3 , 4 , lItem.pszText);
lItem.iItem = 3 + (nColNum - 1) * 3;
lItem.iSubItem = 5;
if (!m_arData[nColNum - 1].bHT_HDP)
{
swprintf(szzText , L"%s %s" , m_arData[nColNum - 1].szHT_HDP , m_arData[nColNum - 1].szHT_B_HDP);
lItem.pszText=W2T(szzText);
}
else
lItem.pszText = W2T(m_arData[nColNum - 1].szHT_B_HDP);
pDlgSportNews->m_List.SetItemText( 3 + (nColNum - 1) * 3 , 5 , lItem.pszText);
lItem.iItem = 3 + (nColNum - 1) * 3;
lItem.iSubItem = 6;
lItem.pszText = W2T(m_arData[nColNum - 1].szHT_B_UO);
pDlgSportNews->m_List.SetItemText( 3 + (nColNum - 1) * 3 , 6 , lItem.pszText);
lItem.iItem = 3 + (nColNum - 1) * 3;
lItem.iSubItem = 7;
lItem.pszText = W2T(m_arData[nColNum - 1].szHT_D_Odd);
pDlgSportNews->m_List.SetItemText( 3 + (nColNum - 1) * 3 , 7 , lItem.pszText);
pDlgSportNews->m_List.UpdateData();
UpdateData(FALSE);