8 个解决方案
#1
数据量挺大的
#2
修改记录后发个消息给CListctrl,让它自己执行查询不就可以了;
但是这样效率不高,你可以重载DrawItem(LPDRAWITEMSTRUCT lpDIS),来刷新你修改的记录就可以了;
#3
不明白。??CListctrl中的数据重新查询后才能显示 这是指什么
#4
不明白。??CListctrl中的数据重新查询后才能显示 这是指什么
#5
在你修改后,查询CListctrl中看是否有该条记录有就修改其中的内容,
在添加后,直接在CListctrl中插入一行不就行了吗?
在添加后,直接在CListctrl中插入一行不就行了吗?
#6
leechard,你好。。我已经重载了DrawItem,,可是这个函数没被执行?????
#7
现在可以进入DrawItem函数体了,可是DrawItem并没有让添加的记录自动显示在CListctrl上,
说明:我用的是sql server 2005数据库,添加了四项分别是产品编号,产品名称,配比和单价 m_pRecordset->AddNew();
m_pRecordset->PutCollect("ProNo",_variant_t(m_bh));
m_pRecordset->PutCollect("ProName",_variant_t(m_mc));
m_pRecordset->PutCollect("Proportion",_variant_t(m_pb));
m_pRecordset->PutCollect("Price",_variant_t(m_dj));
m_pRecordset->Update();
要想显示还是要查询一下,
说明:我用的是sql server 2005数据库,添加了四项分别是产品编号,产品名称,配比和单价 m_pRecordset->AddNew();
m_pRecordset->PutCollect("ProNo",_variant_t(m_bh));
m_pRecordset->PutCollect("ProName",_variant_t(m_mc));
m_pRecordset->PutCollect("Proportion",_variant_t(m_pb));
m_pRecordset->PutCollect("Price",_variant_t(m_dj));
m_pRecordset->Update();
要想显示还是要查询一下,
#8
DrawItem 函数体为
int nItem=lpDrawItemStruct->itemID;
if(nItem == -1)
return ;
CRect rcCol = lpDrawItemStruct->rcItem;
CString sText;
CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
int nOldDCMode=pDC->SaveDC();
LVITEM item;
item.iItem = nItem;
item.iSubItem = 0;
item.mask = LVIF_IMAGE|LVIF_STATE;
item.stateMask = 0XFFFF;
GetItem(&item);
BOOL bSelected = item.state&LVIS_SELECTED;
COLORREF color=::GetSysColor(COLOR_WINDOW);
if(bSelected ) {
pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
color=::GetSysColor(COLOR_HIGHLIGHT); }
else {
pDC->SetBkColor(color);
pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
}
LV_COLUMN lvc;
lvc.mask=LVCF_FMT|LVCF_WIDTH;
rcCol.right = rcCol.left;
for(int nCol=0; GetColumn(nCol,&lvc); nCol++)
{
rcCol.left = rcCol.right;
rcCol.right = rcCol.left + GetColumnWidth(nCol);
HPEN hOldPen = (HPEN)::SelectObject(lpDrawItemStruct->hDC, ::CreatePen(PS_SOLID, 1, RGB(0xc0,0xc0,0xc0)));
HBRUSH hOldBrush = (HBRUSH)::SelectObject(lpDrawItemStruct->hDC, ::CreateSolidBrush(color));
::Rectangle(lpDrawItemStruct->hDC, rcCol.left-1, rcCol.top-1, rcCol.right, rcCol.bottom);
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldBrush));
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldPen));
// sText=MakeShortString(pDC,GetItemText(nItem,nCol),rcCol.Width());
sText=GetItemText(nItem,nCol);
pDC->DrawText(sText, -1, CRect::CRect(rcCol.left+3,rcCol.top,rcCol.right,rcCol.bottom-2), DT_LEFT);
}
pDC->RestoreDC(nOldDCMode);
问题出在哪了?帮帮我吧。。。
int nItem=lpDrawItemStruct->itemID;
if(nItem == -1)
return ;
CRect rcCol = lpDrawItemStruct->rcItem;
CString sText;
CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
int nOldDCMode=pDC->SaveDC();
LVITEM item;
item.iItem = nItem;
item.iSubItem = 0;
item.mask = LVIF_IMAGE|LVIF_STATE;
item.stateMask = 0XFFFF;
GetItem(&item);
BOOL bSelected = item.state&LVIS_SELECTED;
COLORREF color=::GetSysColor(COLOR_WINDOW);
if(bSelected ) {
pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
color=::GetSysColor(COLOR_HIGHLIGHT); }
else {
pDC->SetBkColor(color);
pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
}
LV_COLUMN lvc;
lvc.mask=LVCF_FMT|LVCF_WIDTH;
rcCol.right = rcCol.left;
for(int nCol=0; GetColumn(nCol,&lvc); nCol++)
{
rcCol.left = rcCol.right;
rcCol.right = rcCol.left + GetColumnWidth(nCol);
HPEN hOldPen = (HPEN)::SelectObject(lpDrawItemStruct->hDC, ::CreatePen(PS_SOLID, 1, RGB(0xc0,0xc0,0xc0)));
HBRUSH hOldBrush = (HBRUSH)::SelectObject(lpDrawItemStruct->hDC, ::CreateSolidBrush(color));
::Rectangle(lpDrawItemStruct->hDC, rcCol.left-1, rcCol.top-1, rcCol.right, rcCol.bottom);
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldBrush));
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldPen));
// sText=MakeShortString(pDC,GetItemText(nItem,nCol),rcCol.Width());
sText=GetItemText(nItem,nCol);
pDC->DrawText(sText, -1, CRect::CRect(rcCol.left+3,rcCol.top,rcCol.right,rcCol.bottom-2), DT_LEFT);
}
pDC->RestoreDC(nOldDCMode);
问题出在哪了?帮帮我吧。。。
#1
数据量挺大的
#2
修改记录后发个消息给CListctrl,让它自己执行查询不就可以了;
但是这样效率不高,你可以重载DrawItem(LPDRAWITEMSTRUCT lpDIS),来刷新你修改的记录就可以了;
#3
不明白。??CListctrl中的数据重新查询后才能显示 这是指什么
#4
不明白。??CListctrl中的数据重新查询后才能显示 这是指什么
#5
在你修改后,查询CListctrl中看是否有该条记录有就修改其中的内容,
在添加后,直接在CListctrl中插入一行不就行了吗?
在添加后,直接在CListctrl中插入一行不就行了吗?
#6
leechard,你好。。我已经重载了DrawItem,,可是这个函数没被执行?????
#7
现在可以进入DrawItem函数体了,可是DrawItem并没有让添加的记录自动显示在CListctrl上,
说明:我用的是sql server 2005数据库,添加了四项分别是产品编号,产品名称,配比和单价 m_pRecordset->AddNew();
m_pRecordset->PutCollect("ProNo",_variant_t(m_bh));
m_pRecordset->PutCollect("ProName",_variant_t(m_mc));
m_pRecordset->PutCollect("Proportion",_variant_t(m_pb));
m_pRecordset->PutCollect("Price",_variant_t(m_dj));
m_pRecordset->Update();
要想显示还是要查询一下,
说明:我用的是sql server 2005数据库,添加了四项分别是产品编号,产品名称,配比和单价 m_pRecordset->AddNew();
m_pRecordset->PutCollect("ProNo",_variant_t(m_bh));
m_pRecordset->PutCollect("ProName",_variant_t(m_mc));
m_pRecordset->PutCollect("Proportion",_variant_t(m_pb));
m_pRecordset->PutCollect("Price",_variant_t(m_dj));
m_pRecordset->Update();
要想显示还是要查询一下,
#8
DrawItem 函数体为
int nItem=lpDrawItemStruct->itemID;
if(nItem == -1)
return ;
CRect rcCol = lpDrawItemStruct->rcItem;
CString sText;
CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
int nOldDCMode=pDC->SaveDC();
LVITEM item;
item.iItem = nItem;
item.iSubItem = 0;
item.mask = LVIF_IMAGE|LVIF_STATE;
item.stateMask = 0XFFFF;
GetItem(&item);
BOOL bSelected = item.state&LVIS_SELECTED;
COLORREF color=::GetSysColor(COLOR_WINDOW);
if(bSelected ) {
pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
color=::GetSysColor(COLOR_HIGHLIGHT); }
else {
pDC->SetBkColor(color);
pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
}
LV_COLUMN lvc;
lvc.mask=LVCF_FMT|LVCF_WIDTH;
rcCol.right = rcCol.left;
for(int nCol=0; GetColumn(nCol,&lvc); nCol++)
{
rcCol.left = rcCol.right;
rcCol.right = rcCol.left + GetColumnWidth(nCol);
HPEN hOldPen = (HPEN)::SelectObject(lpDrawItemStruct->hDC, ::CreatePen(PS_SOLID, 1, RGB(0xc0,0xc0,0xc0)));
HBRUSH hOldBrush = (HBRUSH)::SelectObject(lpDrawItemStruct->hDC, ::CreateSolidBrush(color));
::Rectangle(lpDrawItemStruct->hDC, rcCol.left-1, rcCol.top-1, rcCol.right, rcCol.bottom);
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldBrush));
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldPen));
// sText=MakeShortString(pDC,GetItemText(nItem,nCol),rcCol.Width());
sText=GetItemText(nItem,nCol);
pDC->DrawText(sText, -1, CRect::CRect(rcCol.left+3,rcCol.top,rcCol.right,rcCol.bottom-2), DT_LEFT);
}
pDC->RestoreDC(nOldDCMode);
问题出在哪了?帮帮我吧。。。
int nItem=lpDrawItemStruct->itemID;
if(nItem == -1)
return ;
CRect rcCol = lpDrawItemStruct->rcItem;
CString sText;
CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
int nOldDCMode=pDC->SaveDC();
LVITEM item;
item.iItem = nItem;
item.iSubItem = 0;
item.mask = LVIF_IMAGE|LVIF_STATE;
item.stateMask = 0XFFFF;
GetItem(&item);
BOOL bSelected = item.state&LVIS_SELECTED;
COLORREF color=::GetSysColor(COLOR_WINDOW);
if(bSelected ) {
pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
color=::GetSysColor(COLOR_HIGHLIGHT); }
else {
pDC->SetBkColor(color);
pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
}
LV_COLUMN lvc;
lvc.mask=LVCF_FMT|LVCF_WIDTH;
rcCol.right = rcCol.left;
for(int nCol=0; GetColumn(nCol,&lvc); nCol++)
{
rcCol.left = rcCol.right;
rcCol.right = rcCol.left + GetColumnWidth(nCol);
HPEN hOldPen = (HPEN)::SelectObject(lpDrawItemStruct->hDC, ::CreatePen(PS_SOLID, 1, RGB(0xc0,0xc0,0xc0)));
HBRUSH hOldBrush = (HBRUSH)::SelectObject(lpDrawItemStruct->hDC, ::CreateSolidBrush(color));
::Rectangle(lpDrawItemStruct->hDC, rcCol.left-1, rcCol.top-1, rcCol.right, rcCol.bottom);
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldBrush));
::DeleteObject(SelectObject(lpDrawItemStruct->hDC, hOldPen));
// sText=MakeShortString(pDC,GetItemText(nItem,nCol),rcCol.Width());
sText=GetItemText(nItem,nCol);
pDC->DrawText(sText, -1, CRect::CRect(rcCol.left+3,rcCol.top,rcCol.right,rcCol.bottom-2), DT_LEFT);
}
pDC->RestoreDC(nOldDCMode);
问题出在哪了?帮帮我吧。。。