Adding Items ti List control
-
Hi , From the below code it displays the file name on the output screen,can anyone please tell how to add them to List box ?? I have list box IDC_OUTPUT CListCtrl m_output. ----------------------------------- if (e != NULL) { readFiles (e->left); fp = fopen (e->filename, "r"); fnum++; if ((s = (char*)strrchr(e->filename, '/')) == NULL) cout << e->filename; //Prints file name else cout << e->filename; //Prints File name insert (fnum, e->filename); if (fp) { wds = getWord (fp,fnum); } cout << " (" << wds << " words)" << endl; //Prints number of words fclose (fp); ------------------------------------ Regards, Parichay.
-
Hi , From the below code it displays the file name on the output screen,can anyone please tell how to add them to List box ?? I have list box IDC_OUTPUT CListCtrl m_output. ----------------------------------- if (e != NULL) { readFiles (e->left); fp = fopen (e->filename, "r"); fnum++; if ((s = (char*)strrchr(e->filename, '/')) == NULL) cout << e->filename; //Prints file name else cout << e->filename; //Prints File name insert (fnum, e->filename); if (fp) { wds = getWord (fp,fnum); } cout << " (" << wds << " words)" << endl; //Prints number of words fclose (fp); ------------------------------------ Regards, Parichay.
hi parichaya, u want to add to ListBox or ListControl? r u from AP?
-
Hi , From the below code it displays the file name on the output screen,can anyone please tell how to add them to List box ?? I have list box IDC_OUTPUT CListCtrl m_output. ----------------------------------- if (e != NULL) { readFiles (e->left); fp = fopen (e->filename, "r"); fnum++; if ((s = (char*)strrchr(e->filename, '/')) == NULL) cout << e->filename; //Prints file name else cout << e->filename; //Prints File name insert (fnum, e->filename); if (fp) { wds = getWord (fp,fnum); } cout << " (" << wds << " words)" << endl; //Prints number of words fclose (fp); ------------------------------------ Regards, Parichay.
CListBox or CListCtrl?
-
CListBox or CListCtrl?
Hi, Thanks for the reply, its CListCtrl,
-
Hi , From the below code it displays the file name on the output screen,can anyone please tell how to add them to List box ?? I have list box IDC_OUTPUT CListCtrl m_output. ----------------------------------- if (e != NULL) { readFiles (e->left); fp = fopen (e->filename, "r"); fnum++; if ((s = (char*)strrchr(e->filename, '/')) == NULL) cout << e->filename; //Prints file name else cout << e->filename; //Prints File name insert (fnum, e->filename); if (fp) { wds = getWord (fp,fnum); } cout << " (" << wds << " words)" << endl; //Prints number of words fclose (fp); ------------------------------------ Regards, Parichay.
Use
InsertItem
ofCListCtrl
. There is an example inMSDN
related to this. Please look upInsertItem
. I guess here you will have to use the report style(LVS_REPORT
).
Nibu thomas Software Developer Faqs by Michael dunn
-
hi parichaya, u want to add to ListBox or ListControl? r u from AP?
Hi, its List Control. I am from Bangalore.
-
Use
InsertItem
ofCListCtrl
. There is an example inMSDN
related to this. Please look upInsertItem
. I guess here you will have to use the report style(LVS_REPORT
).
Nibu thomas Software Developer Faqs by Michael dunn
Hi, Thanks for the reply..I just checked the MSDN Ex.. --------------------- Example MSDN // The pointer to my list view control. extern CListCtrl* pmyListCtrl; CString strText; int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount(); // Insert 10 items in the list view control. for (int i=0;i < 10;i++) { strText.Format(TEXT("item %d"), i); // Insert the item, select every other item. pmyListCtrl->InsertItem( LVIF_TEXT|LVIF_STATE, i, strText, (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED, 0, 0); // Initialize the text of the subitems. for (int j=1;j < nColumnCount;j++) { strText.Format(TEXT("sub-item %d %d"), i, j); pmyListCtrl->SetItemText(i, j, strText); } } ---------------------------------------- extern CListCtrl* pmyListCtrl; can u tell me what the use of the above statment ??
-
Hi, Thanks for the reply..I just checked the MSDN Ex.. --------------------- Example MSDN // The pointer to my list view control. extern CListCtrl* pmyListCtrl; CString strText; int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount(); // Insert 10 items in the list view control. for (int i=0;i < 10;i++) { strText.Format(TEXT("item %d"), i); // Insert the item, select every other item. pmyListCtrl->InsertItem( LVIF_TEXT|LVIF_STATE, i, strText, (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED, 0, 0); // Initialize the text of the subitems. for (int j=1;j < nColumnCount;j++) { strText.Format(TEXT("sub-item %d %d"), i, j); pmyListCtrl->SetItemText(i, j, strText); } } ---------------------------------------- extern CListCtrl* pmyListCtrl; can u tell me what the use of the above statment ??
parichaybp wrote:
extern CListCtrl* pmyListCtrl; can u tell me what the use of the above statment ??
This is just an indication that
pmyListCtrl
is declared elsewhere. Most of the samples have this kind of declaration. You can ignore this and concentrate on the essentials.
Nibu thomas Software Developer Faqs by Michael dunn
-
Hi, Thanks for the reply..I just checked the MSDN Ex.. --------------------- Example MSDN // The pointer to my list view control. extern CListCtrl* pmyListCtrl; CString strText; int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount(); // Insert 10 items in the list view control. for (int i=0;i < 10;i++) { strText.Format(TEXT("item %d"), i); // Insert the item, select every other item. pmyListCtrl->InsertItem( LVIF_TEXT|LVIF_STATE, i, strText, (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED, 0, 0); // Initialize the text of the subitems. for (int j=1;j < nColumnCount;j++) { strText.Format(TEXT("sub-item %d %d"), i, j); pmyListCtrl->SetItemText(i, j, strText); } } ---------------------------------------- extern CListCtrl* pmyListCtrl; can u tell me what the use of the above statment ??
parichaybp wrote:
extern CListCtrl* pmyListCtrl;
Meaning the variable
CListCtrl* pmyListCtrl
is declared somewhere else (another .cpp file) outside this cpp file.
Maxwell Chen
-
Hi , From the below code it displays the file name on the output screen,can anyone please tell how to add them to List box ?? I have list box IDC_OUTPUT CListCtrl m_output. ----------------------------------- if (e != NULL) { readFiles (e->left); fp = fopen (e->filename, "r"); fnum++; if ((s = (char*)strrchr(e->filename, '/')) == NULL) cout << e->filename; //Prints file name else cout << e->filename; //Prints File name insert (fnum, e->filename); if (fp) { wds = getWord (fp,fnum); } cout << " (" << wds << " words)" << endl; //Prints number of words fclose (fp); ------------------------------------ Regards, Parichay.
void CAnswerView::FillList(CListCtrl *m_ListCtrl,CListBox *m_ListBox,CString str) { if(m_ListCtrl) { LV_ITEM Item2={0}; Item2 .mask = LVIF_TEXT| LVIF_STATE|LVIF_PARAM; Item2 .iItem =m_ListCtrl->GetItemCount(); Item2 .pszText = CA2T(str); Item2 .stateMask = LVIS_STATEIMAGEMASK; Item2 .state = INDEXTOSTATEIMAGEMASK(1); m_ListCtrl->InsertItem( &Item2); } if(m_ListBox) { m_ListBox->AddString(str); m_ListBox->InsertString(0,str); } }
-
parichaybp wrote:
extern CListCtrl* pmyListCtrl;
Meaning the variable
CListCtrl* pmyListCtrl
is declared somewhere else (another .cpp file) outside this cpp file.
Maxwell Chen
Hi Maxwell Chen, Hope U still Remember me..:) i just tried with this statment CString strText = "hello"; m_OUTPUT->SetItemText(1, 1, strText); is this correct ???
-
Hi Maxwell Chen, Hope U still Remember me..:) i just tried with this statment CString strText = "hello"; m_OUTPUT->SetItemText(1, 1, strText); is this correct ???
-
void CAnswerView::FillList(CListCtrl *m_ListCtrl,CListBox *m_ListBox,CString str) { if(m_ListCtrl) { LV_ITEM Item2={0}; Item2 .mask = LVIF_TEXT| LVIF_STATE|LVIF_PARAM; Item2 .iItem =m_ListCtrl->GetItemCount(); Item2 .pszText = CA2T(str); Item2 .stateMask = LVIS_STATEIMAGEMASK; Item2 .state = INDEXTOSTATEIMAGEMASK(1); m_ListCtrl->InsertItem( &Item2); } if(m_ListBox) { m_ListBox->AddString(str); m_ListBox->InsertString(0,str); } }
Hi WhiteSky, CListCtrl *m_OUTPUT; CString strText = "hello"; m_OUTPUT->SetItemText(1, 1, strText); is the above statment correct ?? i tryed but its not giveing any output.
-
Hi WhiteSky, CListCtrl *m_OUTPUT; CString strText = "hello"; m_OUTPUT->SetItemText(1, 1, strText); is the above statment correct ?? i tryed but its not giveing any output.
CListCtrl::SetItemText
is to alter the text of an existing entry in that CListCtrl. If there has not any entry in that control, what you are using is invalid. Thus we have suggested you to useCListCtrl::InsertItem
.
Maxwell Chen
-
Hi WhiteSky, CListCtrl *m_OUTPUT; CString strText = "hello"; m_OUTPUT->SetItemText(1, 1, strText); is the above statment correct ?? i tryed but its not giveing any output.
I suggest that you read Msdn also example from ClistCtrl
-
Hi, Thanks for the reply..I just checked the MSDN Ex.. --------------------- Example MSDN // The pointer to my list view control. extern CListCtrl* pmyListCtrl; CString strText; int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount(); // Insert 10 items in the list view control. for (int i=0;i < 10;i++) { strText.Format(TEXT("item %d"), i); // Insert the item, select every other item. pmyListCtrl->InsertItem( LVIF_TEXT|LVIF_STATE, i, strText, (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED, 0, 0); // Initialize the text of the subitems. for (int j=1;j < nColumnCount;j++) { strText.Format(TEXT("sub-item %d %d"), i, j); pmyListCtrl->SetItemText(i, j, strText); } } ---------------------------------------- extern CListCtrl* pmyListCtrl; can u tell me what the use of the above statment ??
parichaybp wrote:
extern CListCtrl* pmyListCtrl; can u tell me what the use of the above statment ??
And that's why I have suggested you to read a book about the syntax of C++ Language.
Maxwell Chen
-
Hi, its List Control. I am from Bangalore.
hii, where r u working in b'lore?
-
hii, where r u working in b'lore?
Hey i am nt working,i am doing my MCA project work.
-
Hey i am nt working,i am doing my MCA project work.
good. may i know on which project u r doing? ur name?