具有报表视图样式的黑色网格线的多行文本ListCtrl [英] Multiline text ListCtrl with black color grid line of Report View Style

查看:90
本文介绍了具有报表视图样式的黑色网格线的多行文本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?

推荐答案

否.错误源位于您的DrawItem():)
No. The error source is placed at your DrawItem() :)


尝试并扩展它:)

Try and extend it :)

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;
  }
}


您应该使用pDC->FillSolidRect(cRect, <YourRGB>);

在您的DrawItem()中:)

请不要将其注释掉:)
You should use pDC->FillSolidRect(cRect, <YourRGB>);

in your DrawItem() :)

Please do not comment it out :)


这篇关于具有报表视图样式的黑色网格线的多行文本ListCtrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆