Cagan
May 15th, 1998, 01:05 AM
For a report-style CListCtrl, I use SetItemData() method to store some values, when I use GetItemData() I get 0 (zero) especially for the first item in the control whereas the real value has nothing to do with it.
Any ideas?
Thanks
riechard
May 18th, 1998, 03:03 AM
I haven't discovered a problem like this using the report-style CListCtrl. I think you should
check the indexes for a 0/1 base problem.
Philip Nickoll
May 21st, 1998, 04:12 AM
I also seem to be suffering from a similiar problem - the SetItem function always returns 0 (i.e. a failure). I am using a CListView derived class and call set data like this
GetListCtrl ().SetItem(&lv);
where lv is a LV_ITEM structure.
This function call (SetItem) however works fine if I use a CListCtrl derived class.
Any ideas of why this is happening or better yet how to solve this problem would be greatly appreciated.
Thanks in advance
Philip Nickoll
Torkel
May 31st, 1998, 10:02 AM
You might only need to use SetItemState(). It works better.
Torkel
Denis Dagenais
August 17th, 1998, 09:21 AM
Try using the following:
Single column:
unsigned short ChannelList[128]; // max channels
unsigned short ubNumChannels;
UCHAR szChan[4];
m_ChannelListCTL.DeleteAllItems();
ubNumChannels=theCollector->getChannelList(ChannelList);
for (int i=0;i< ubNumChannels;i++)
{
itoa(ChannelList[i] ,(char*)szChan,10);
m_MyClistCtrl.InsertItem(i,(char*)szChan);
} //for (int i=0;i< ubNumChannels;i++)
Multi-column:
LV_ITEM lviValues;
int iCount;
char sPower[15], sVoltage[15];
iCount = m_AcquiredValuesListCTL.GetItemCount();
sprintf(sPower,"%.3lf", m_InputPower );
sprintf( sVoltage,"%.4lf",m_AcquiredVoltage);
lviValues.mask=LVIF_TEXT;
lviValues.iSubItem=0;
lviValues.pszText= sPower;
lviValues.cchTextMax = 15;
m_AcquiredValuesListCTL.InsertItem(&lviValues);
m_AcquiredValuesListCTL.SetItemText(iCount,1,sVoltage);
and now to retrieve:
Single column:
iCountValues = m_AcquiredValuesListCTL.GetItemCount();
for (int i=0;i< iCountValues;i++)
// load the arrays from the Values list
{
m_AcquiredValuesListCTL.GetItemText(i,0,sPower,sizeof(sPower));
}//for (int i=0;i< iCountValues;i++)
multi-column:
iCountValues = m_AcquiredValuesListCTL.GetItemCount();
for (int i=0;i< iCountValues;i++)
// load the arrays from the Values list
{
m_AcquiredValuesListCTL.GetItemText(i,0,sPower,sizeof(sPower));
m_AcquiredValuesListCTL.GetItemText(i,1,sVoltage,sizeof(sVoltage));
}//for (int i=0;i< iCountValues;i++)