can't add elements in the column
-
Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh
-
Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh
kamalesh82 wrote:
strItem.Format(_T(&TP->TR.Account[1]));
The
_T()
macro is only needed with string literals. Also, why use theFormat()
method when you can assign&TP->TR.Account[1]
directly tostrItem
? Try:int nItem = m_cListCtrl.InsertItem(0, &TP->TR.Account[1]);
m_cListCtrl.SetItemText(nItem, 1, &TP->TR.ExpDate[1]);
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
-
kamalesh82 wrote:
strItem.Format(_T(&TP->TR.Account[1]));
The
_T()
macro is only needed with string literals. Also, why use theFormat()
method when you can assign&TP->TR.Account[1]
directly tostrItem
? Try:int nItem = m_cListCtrl.InsertItem(0, &TP->TR.Account[1]);
m_cListCtrl.SetItemText(nItem, 1, &TP->TR.ExpDate[1]);
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
&TP->TR.Account[1] returns the string literal.so be sure that it's not making any problem. nd i used SetItemText as well as the SetItem both function. Good Day kamalesh
-
Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh
Hi, here is my example without lvItem structure:
// this works! i -> my linenumber and 1 is the first subitem! ctrlList->SetItem(i, 1, LVIF_TEXT, MyTextHere, 0,NULL, NULL, 0); // i dont try this, but you can do this! //you can change to lvItem.iSubItem = 1; ctrlList.Setitem(&lvItem);
i hope that helps! regards break; -- modified at 10:07 Thursday 6th July, 2006 -
Hi i've strange problem.i've 4 columns Account,date,amount,address in a Clist Control. //a breif abt my project in my project am trying to slect a file by browsing (i used cfiledialog). & then pressing the button 'showbutton' i want to see all the documents(i.e.account,date,amount,address) of that file.this file is actually a list of several transaction......... now in this project i didn't use classwizard, all the message mapping,dialog creation i've done mannually............... //the problem now, the problem is, while am trynig to insert items in the r8 column, only the 1st column is being populated , not the others....in the insertion column CString strItem; LVITEM lvi; lvi.mask = LVIF_TEXT; //Account no... strItem.Format(_T(&TP->TR.Account[1])); lvi.iSubItem = 0; lvi.pszText = (LPTSTR)(LPCTSTR)(strItem); m_cListCtrl.InsertItem( &lvi); //Expirary Date strItem.Format(_T(&TP->TR.ExpDate[1])); lvi.iSubItem = 1; lvi.pszText = (LPTSTR)(LPCTSTR)( strItem); m_cListCtrl.InsertItem( &lvi); nd this way only putting "lvi.iSubItem=2,3...4" Don't get confused with TP,TR...these r my project variables for other issues. using that above code.. am getting only 1st column.... waiting for quick reply.....A GOOD DAY to all. kamalesh
you should set the itemidentifier for the subitem, subitem must to know to witch item is to add!? i solve your problem like this:
// one lvItem only for SubItems LVITEM lvItem; lvItem.iItem = 0; // this is important!!! can be any linenumber from your listctrl! lvItem.iSubItem = 1; // first subitem lvItem.mask = LVIF_TEXT; // example for iterating: int i = 0; while(i < 10) { // listctrl have only two columns! // Set Subitems Text to 10 Items! lvItem.iItem = i; // first item(first line in the listctrl) //lvItem.iSubItem = 1; // first subitem, stay the same, we dont need to change them here! lvItem.pszText = (LPTSTR)(LPCTSTR) NewText; listCtrl->SetItem(&lvItem); i++; }
i try this and it works! regards break; -- modified at 10:43 Thursday 6th July, 2006