本文介绍了具有报表视图样式的黑色网格线的多行文本ListCtrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我确实想在报表视图样式的ListCtrl中显示多行文本.
在显示数据时,我确实希望使用Reoprt视图样式的黑色网格线.
有人可以帮我吗?
Hello,
I do want to display multiline text in ListCtrl of Report View Style.
While displaying data, i do want black color grid lines in Reoprt View Style.
Anyone can help me out in this?
推荐答案
void CMainForm::OnInitialUpdate()
{
UpdateData(FALSE);
m_cList.InsertColumn(0, _T("col 1"), LVCFMT_LEFT, 200);
m_cList.InsertColumn(1, _T("col 2"), LVCFMT_LEFT, 200);
m_cList.InsertItem(0, _T("item 1"));
m_cList.SetItemText(0, 1, _T("comment 1"));
m_cList.InsertItem(1, _T("item 2"));
m_cList.SetItemText(1, 1, _T("comment 2"));
m_cList.InsertItem(2, _T("item 3"));
m_cList.SetItemText(2, 1, _T("comment 3"));
m_cList.InsertItem(3, _T("item 4"));
m_cList.SetItemText(3, 1, _T("comment 4"));
}
void CColoredListReport::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC;
pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
switch (lpDrawItemStruct->itemAction) {
case ODA_DRAWENTIRE:
CRect cRect(lpDrawItemStruct->rcItem);
cRect.DeflateRect(0, 0, 1, 1);
pDC->FillSolidRect(cRect, RGB(255, 249, 121));
// The row frame
pDC->MoveTo(cRect.left, cRect.bottom);
pDC->LineTo(cRect.right, cRect.bottom);
pDC->LineTo(cRect.right, cRect.top -1);
// The cells frames and textes
CRect cSubItemRect;
GetSubItemRect(lpDrawItemStruct->itemID, 0, LVIR_LABEL, cSubItemRect);
pDC->DrawText(GetItemText(0, 0), cSubItemRect, DT_CENTER|DT_VCENTER);
GetSubItemRect(lpDrawItemStruct->itemID, 1, LVIR_LABEL, cSubItemRect);
pDC->MoveTo(cSubItemRect.TopLeft());
pDC->LineTo(cSubItemRect.left, cSubItemRect.bottom);
pDC->DrawText(GetItemText(0, 1), cSubItemRect, DT_CENTER|DT_VCENTER);
break;
}
}
这篇关于具有报表视图样式的黑色网格线的多行文本ListCtrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!