// JP opened flex table

Click to See Complete Forum and Search --> : CListCtrl.GetItemData()


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

&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;i=0;i<&nbsp;ubNumChannels;i++)

&nbsp;&nbsp;&nbsp;&nbsp;{

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;itoa(ChannelList[i]&nbsp;,(char*)szChan,10);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_MyClistCtrl.InsertItem(i,(char*)szChan);


&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;//for&nbsp;(int&nbsp;i=0;i<&nbsp;ubNumChannels;i++)



Multi-column:


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LV_ITEM&nbsp;lviValues;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;iCount;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;sPower[15],&nbsp;sVoltage[15];


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iCount&nbsp;=&nbsp;m_AcquiredValuesListCTL.GetItemCount();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprintf(sPower,"%.3lf",&nbsp;m_InputPower&nbsp;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprintf(&nbsp;sVoltage,"%.4lf",m_AcquiredVoltage);


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lviValues.mask=LVIF_TEXT;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lviValues.iSubItem=0;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lviValues.pszText=&nbsp;sPower;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lviValues.cchTextMax&nbsp;=&nbsp;15;

m_AcquiredValuesListCTL.InsertItem(&lviValues);

m_AcquiredValuesListCTL.SetItemText(iCount,1,sVoltage);


and&nbsp;now&nbsp;to&nbsp;retrieve:


Single&nbsp;column:

&nbsp;&nbsp;&nbsp;&nbsp;iCountValues&nbsp;=&nbsp;m_AcquiredValuesListCTL.GetItemCount();

&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;i=0;i<&nbsp;iCountValues;i++)

&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;load&nbsp;the&nbsp;arrays&nbsp;from&nbsp;the&nbsp;Values&nbsp;list

&nbsp;&nbsp;&nbsp;&nbsp;{

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_AcquiredValuesListCTL.GetItemText(i,0,sPower,sizeof(sPower));

&nbsp;&nbsp;&nbsp;&nbsp;}//for&nbsp;(int&nbsp;i=0;i<&nbsp;iCountValues;i++)


multi-column:

&nbsp;&nbsp;&nbsp;&nbsp;iCountValues&nbsp;=&nbsp;m_AcquiredValuesListCTL.GetItemCount();

&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;i=0;i<&nbsp;iCountValues;i++)

&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;load&nbsp;the&nbsp;arrays&nbsp;from&nbsp;the&nbsp;Values&nbsp;list

&nbsp;&nbsp;&nbsp;&nbsp;{

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_AcquiredValuesListCTL.GetItemText(i,0,sPower,sizeof(sPower));

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_AcquiredValuesListCTL.GetItemText(i,1,sVoltage,sizeof(sVoltage));

&nbsp;&nbsp;&nbsp;&nbsp;}//for&nbsp;(int&nbsp;i=0;i<&nbsp;iCountValues;i++)



&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;

//JP added flex table