Click here to Skip to main content
15,925,781 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralNeed help quick on a couple of silly simple problems Pin
David LeBlanc13-Mar-01 13:30
David LeBlanc13-Mar-01 13:30 
GeneralRe: Need help quick on a couple of silly simple problems Pin
Joe Moldovan13-Mar-01 14:33
Joe Moldovan13-Mar-01 14:33 
GeneralRe: Need help quick on a couple of silly simple problems Pin
Steve Driessens13-Mar-01 17:16
Steve Driessens13-Mar-01 17:16 
GeneralRe: Need help quick on a couple of silly simple problems Pin
Ammar13-Mar-01 20:29
Ammar13-Mar-01 20:29 
GeneralRe: Need help quick on a couple of silly simple problems Pin
Peter Godec14-Mar-01 13:27
Peter Godec14-Mar-01 13:27 
GeneralNeed help quick on a couple of silly simple problems Pin
David LeBlanc13-Mar-01 13:29
David LeBlanc13-Mar-01 13:29 
GeneralQuestion about CListControl Pin
13-Mar-01 12:51
suss13-Mar-01 12:51 
GeneralRe: Question about CListControl Pin
Christian Graus13-Mar-01 23:46
protectorChristian Graus13-Mar-01 23:46 
I'm surprised no-one answered this already - I had to wait to get home and look at code where I did it.

I'm using SetItemText to put them in, but GetItemText takes them back out the same way:

// Create list view columns
LV_COLUMN listColumn;
LV_ITEM listItem;
char* arColumns[2] = { "Account", "Password"};
listColumn.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
listColumn.fmt = LVCFMT_LEFT;
int Width[2]={190,63};
listColumn.cx = 180;
for ( int nColumn = 0;nColumn<2;nColumn++)
{
listColumn.cx = Width[nColumn];
listColumn.iSubItem = nColumn;
listColumn.pszText = arColumns[nColumn];
m_listCtrl.InsertColumn(nColumn,&listColumn);
}

// Add list items

listItem.mask = LVIF_TEXT | LVIF_IMAGE;
listItem.iSubItem = 0;

TCWACCOUNT* pCurrent;
pCurrent = m_TCWACCOUNT.pNext;
int nItem = 0;
while(pCurrent != NULL)
{
listItem.iItem = nItem;
listItem.pszText = pCurrent->pCustName;
CString Check = (CString)pCurrent->pPasswd;
if (Check.Left(4) == "NuLl")
{
listItem.iImage = 1;
m_listCtrl.InsertItem (&listItem);
m_listCtrl.SetItemText (nItem, 1, "No");
}
else
{
listItem.iImage = 0;
m_listCtrl.InsertItem (&listItem);
m_listCtrl.SetItemText (nItem, 1, "Yes");
}
pCurrent = pCurrent->pNext;
nItem++;

}

Ignore all the account stuff, it's just stepping through a linked list. The important part is that the item is the row, the sub item is the column. GetItemText looks like this in the MSDN:

int GetItemText( int nItem, int nSubItem, LPTSTR lpszText, int nLen ) const;

CString GetItemText( int nItem, int nSubItem ) const;

So you can do this

for (int i = 0; i < listsize; i++)
{

Column1[i] = m_List.GetItemText(i, 0);
Column2[i] = m_List.GetItemText(i, 1);
Column3[i] = m_List.GetItemText(i, 2);
}

Of course, you'd be better putting them in a struct ( or class ) but that is another story....



Christian

The content of this post is not necessarily the opinion of my yadda yadda yadda.

To understand recursion, we must first understand recursion.
GeneralDisable CListCtrl Auto Selection Pin
13-Mar-01 11:53
suss13-Mar-01 11:53 
QuestionDo I need Access 2000 royalty free runtime libraries? Pin
Brendan Tregear13-Mar-01 10:24
Brendan Tregear13-Mar-01 10:24 
AnswerRe: Do I need Access 2000 royalty free runtime libraries? Pin
14-Mar-01 4:14
suss14-Mar-01 4:14 
GeneralCould you clarify this for me.... Pin
Brendan Tregear14-Mar-01 15:43
Brendan Tregear14-Mar-01 15:43 
GeneralRe: Could you clarify this for me.... Pin
15-Mar-01 7:41
suss15-Mar-01 7:41 
GeneralThanks for your help (n/t) Pin
Brendan Tregear15-Mar-01 12:04
Brendan Tregear15-Mar-01 12:04 
GeneralGet present URL from Internet Explorer Pin
Vickie13-Mar-01 8:05
Vickie13-Mar-01 8:05 
GeneralRead this in CodeGuru Pin
13-Mar-01 10:39
suss13-Mar-01 10:39 
GeneralHELP! Need a way to show a button in the taskbar... Pin
13-Mar-01 7:40
suss13-Mar-01 7:40 
GeneralRe: HELP! Need a way to show a button in the taskbar... Pin
Christian Graus13-Mar-01 9:35
protectorChristian Graus13-Mar-01 9:35 
GeneralRe: HELP! Need a way to show a button in the taskbar... Pin
Erik Funkenbusch13-Mar-01 12:48
Erik Funkenbusch13-Mar-01 12:48 
GeneralRe: HELP! Need a way to show a button in the taskbar... Pin
Christian Graus13-Mar-01 12:51
protectorChristian Graus13-Mar-01 12:51 
GeneralRe: HELP! Need a way to show a button in the taskbar... Pin
Erik Funkenbusch13-Mar-01 12:47
Erik Funkenbusch13-Mar-01 12:47 
GeneralRe: HELP! Need a way to show a button in the taskbar... Pin
14-Mar-01 23:24
suss14-Mar-01 23:24 
GeneralHELP! Need a way to show a button in the taskbar... Pin
13-Mar-01 7:40
suss13-Mar-01 7:40 
GeneralCRecordSet and Access Database Help Please Pin
13-Mar-01 5:52
suss13-Mar-01 5:52 
GeneralRe: CRecordSet and Access Database Help Please Pin
Tim Deveaux13-Mar-01 6:47
Tim Deveaux13-Mar-01 6:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.