大侠帮助看看:为什么显示不了subitem我重载了
void CTvInquiryView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_tvInquirySet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit(); m_wndList.InsertColumn(0, "index", LVCFMT_LEFT, 100, 0);
m_wndList.InsertColumn(1, "accountnum", LVCFMT_LEFT, 100, 1);
m_wndList.InsertColumn(2, "channelname", LVCFMT_LEFT, 100, 2);
m_wndList.InsertColumn(3, "year", LVCFMT_LEFT, 50, 3);
m_wndList.InsertColumn(4, "month", LVCFMT_LEFT, 50, 4);
m_wndList.InsertColumn(5, "day", LVCFMT_LEFT, 50, 5);
m_wndList.InsertColumn(6, "hour", LVCFMT_LEFT, 50, 6);
m_wndList.InsertColumn(7, "minute", LVCFMT_LEFT, 50, 7);
}void CTvInquiryView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
for(long i=0; i<m_pSet->GetRecordCount(); i++)
{
m_wndList.InsertItem(i, m_pSet->m_index);//index能显出
m_wndList.SetItemText(0, 1, m_pSet->m_account);//不行?
m_wndList.SetItemText(0, 2, m_pSet->m_channel);//不行?
m_wndList.SetItemText(0, 3, m_pSet->m_year);//不行?
m_wndList.SetItemText(0, 4, m_pSet->m_month);//不行?
m_wndList.SetItemText(0, 5, m_pSet->m_day);//不行?
m_wndList.SetItemText(0, 6, m_pSet->m_hour);//不行?
m_wndList.SetItemText(0, 7, m_pSet->m_minute);//不行? m_pSet->MoveNext();
}
m_pSet->MoveFirst();
}
小弟先谢过
void CTvInquiryView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_tvInquirySet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit(); m_wndList.InsertColumn(0, "index", LVCFMT_LEFT, 100, 0);
m_wndList.InsertColumn(1, "accountnum", LVCFMT_LEFT, 100, 1);
m_wndList.InsertColumn(2, "channelname", LVCFMT_LEFT, 100, 2);
m_wndList.InsertColumn(3, "year", LVCFMT_LEFT, 50, 3);
m_wndList.InsertColumn(4, "month", LVCFMT_LEFT, 50, 4);
m_wndList.InsertColumn(5, "day", LVCFMT_LEFT, 50, 5);
m_wndList.InsertColumn(6, "hour", LVCFMT_LEFT, 50, 6);
m_wndList.InsertColumn(7, "minute", LVCFMT_LEFT, 50, 7);
}void CTvInquiryView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
for(long i=0; i<m_pSet->GetRecordCount(); i++)
{
m_wndList.InsertItem(i, m_pSet->m_index);//index能显出
m_wndList.SetItemText(0, 1, m_pSet->m_account);//不行?
m_wndList.SetItemText(0, 2, m_pSet->m_channel);//不行?
m_wndList.SetItemText(0, 3, m_pSet->m_year);//不行?
m_wndList.SetItemText(0, 4, m_pSet->m_month);//不行?
m_wndList.SetItemText(0, 5, m_pSet->m_day);//不行?
m_wndList.SetItemText(0, 6, m_pSet->m_hour);//不行?
m_wndList.SetItemText(0, 7, m_pSet->m_minute);//不行? m_pSet->MoveNext();
}
m_pSet->MoveFirst();
}
小弟先谢过
m_wndList.InsertItem(i);
m_wndList.SetItemText(0, 0, m_pSet->m_index);
m_wndList.SetItemText(0, 1, m_pSet->m_account);
自己多试几次就知道了
........
m_wndList.SetItemText(i, 1, m_pSet->m_account);//不行?
m_wndList.SetItemText(i, 2, m_pSet->m_channel);//不行?
m_wndList.SetItemText(i, 3, m_pSet->m_year);//不行?
m_wndList.SetItemText(i, 4, m_pSet->m_month);//不行?
m_wndList.SetItemText(i, 5, m_pSet->m_day);//不行?
m_wndList.SetItemText(i, 6, m_pSet->m_hour);//不行?
m_wndList.SetItemText(i, 7, m_pSet->m_minute);//不行?
........
并非程序写错
应该是这样吧:
..
for(long i=0; i<m_pSet->GetRecordCount(); i++)
{
m_wndList.InsertItem(i, m_pSet->m_index);//index能显出
m_wndList.SetItemText(i, 1, m_pSet->m_account);//不行?
m_wndList.SetItemText(i, 2, m_pSet->m_channel);//不行?
m_wndList.SetItemText(i, 3, m_pSet->m_year);//不行?
m_wndList.SetItemText(i, 4, m_pSet->m_month);//不行?
m_wndList.SetItemText(i, 5, m_pSet->m_day);//不行?
m_wndList.SetItemText(i, 6, m_pSet->m_hour);//不行?
m_wndList.SetItemText(i, 7, m_pSet->m_minute);//不行? m_pSet->MoveNext();
}
m_pSet->MoveFirst();
...
m_wndList.InsertItem(m_wndList.GetItemCount() , m_pSet->m_index);//index能显出
m_wndList.SetItemText(m_wndList.GetItemCount()-1, 1, m_pSet->m_account);//不行?
m_wndList.SetItemText(m_wndList.GetItemCount()-1, 2, m_pSet->m_channel);//不行?
你试试是不是你的记录集的问题,你在程序的开始加m_pSet->MoveFirst();
程序改为
void CTvInquiryView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
for(long i=0; i<m_pSet->GetRecordCount(); i++)
{
m_wndList.InsertItem(i, m_pSet->m_index);//index能显出
m_wndList.SetItemText(0, 1, m_pSet->m_account);//不行?
m_wndList.SetItemText(0, 2, m_pSet->m_channel);//不行?
m_wndList.SetItemText(0, 3, m_pSet->m_year);//不行?
m_wndList.SetItemText(0, 4, m_pSet->m_month);//不行?
m_wndList.SetItemText(0, 5, m_pSet->m_day);//不行?
m_wndList.SetItemText(0, 6, m_pSet->m_hour);//不行?
m_wndList.SetItemText(0, 7, m_pSet->m_minute);//不行? m_pSet->MoveNext();
}
m_pSet->MoveFirst();
}
m_wndList.InsertItem(0, "k");//pSet->m_index);
m_wndList.SetItemText(0, 1, "SL");//m_pSet->m_account);
m_wndList.SetItemText(0, 2, "SL");//m_pSet->m_channel);
m_wndList.SetItemText(0, 3, "HAPPY");//m_pSet->m_year);
m_wndList.SetItemText(0, 4, "SL");//m_pSet->m_month);
m_wndList.SetItemText(0, 5, "SL");//m_pSet->m_day);
m_wndList.SetItemText(0, 6, "SL");//m_pSet->m_hour);
m_wndList.SetItemText(0, 7, "SL");//m_pSet->m_minute);
可是,listctrl的只有第一行有一个“k”subitem什么也没有。