Hi all Iam facing problem in listview .Problem is while giving breakpoint I can see values are getting updated but when i am seeing LISTVIEW in my application ,its not getting updated. Code: Code Below iam giving breakpoints latitude & longitude values are changing but when i run my application in Listview latitude & longitude are not changing. I try to give invalidate() as well as update but it did not worked it out CString strLstItem; CListCtrl &objLstCtrl = GetListCtrl(); strLstItem.Format("%f", latitude); objLstCtrl.SetItemText(nItem, 1, strLstItem); strLstItem.Format("%f", longitude); objLstCtrl.SetItemText(nItem, 2, strLstItem);
Re: CListCtrl problem It may be the case of Painting of the control and try giving an Invalidate to see if it updates after that,
Then you are updating some other variable and not the one associated with the control which is visible.
No Shabbir I am updating that variable only because i can see while giving breakpoint value are getting updated Code: CString strLstItem; CListCtrl &objLstCtrl = GetListCtrl(); strLstItem.Format("%f", latitude); objLstCtrl.SetItemText(nItem, 1, strLstItem); [B]objLstCtrl.Invalidate();[/B] strLstItem.Format("%f", longitude); objLstCtrl.SetItemText(nItem, 2, strLstItem); [B]objLstCtrl.Invalidate();[/B] But still cant fix out this bug
Are you actually adding an item to the list first? You can't set an item's text until there is an item in the list. Where is nItem coming from? There should be a call somewhere like: Code: [COLOR="Red"]int nItem=objLstCtrl.InsertItem(0,_T("Latitude:"));[/COLOR] strLstItem.Format("%f", latitude); objLstCtrl.SetItemText(nItem, 1, strLstItem);
Here is the whole function iam pasting will it be help for u Code: void CEntityListView::AddEntityToList(int pPosition, TARGET_POS cursor) int [B]nItem[/B];// =0; CString strLstItem; CListCtrl &objLstCtrl = GetListCtrl(); int nLstCount = objLstCtrl.GetItemCount(); //(r)Retrieves the number of items in a list view control. if(nLstCount == 0) { POSITION position; position = ((CScenGenDoc*)m_pDocument)->GetFirstViewPosition(); while(position != NULL) { CView *pView = ((CScenGenDoc*)m_pDocument)->GetNextView(position); if(pView->IsKindOf(RUNTIME_CLASS(CEntityDetailInfoView))) { ((CEntityDetailInfoView*)pView)->SetEntityIndex(1); } } } if(pPosition > nLstCount) { strLstItem.Format("%6d", pPosition); nItem = objLstCtrl.InsertItem(nLstCount, strLstItem); } else { [B]nItem [/B]= pPosition; } latitude = cursor->L_Latitude; longitude = cursor->L_Longitude; strLstItem.Format("%f",latitude); objLstCtrl.SetItemText([B]nItem[/B], 2, strLstItem); strLstItem.Format("%f", longitude); objLstCtrl.SetItemText([B]nItem[/B], 3, strLstItem);
I certainly don't see anything there that looks out of place. Are there any warnings or anything else that might indicate some other problem? I'm at a loss at this point.