Add items in list box
-
Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC
-
Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC
Preeti9 wrote:
I would appreciate if someone let me know how to add items in LIST BOX using MFC.
Use
CListBox::AddString()
orCListBox::InsertString()
.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC
if the content is static ( will be filled once with constant values ) then, you can add them directly in the resource editor ( no code needed for that ). if the contenct is dynamic, you can use
CListBox::AddString
orCListBox::InsertString
( you need to code this ).
Maximilien Lincourt Your Head A Splode - Strong Bad
-
Preeti9 wrote:
I would appreciate if someone let me know how to add items in LIST BOX using MFC.
Use
CListBox::AddString()
orCListBox::InsertString()
.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
Thanks for your help. Should it be like this: [\code] CListBox::AddString() { AddString("USA"); AddString("CANADA"); ..... .. } C++Prog
-
Thanks for your help. Should it be like this: [\code] CListBox::AddString() { AddString("USA"); AddString("CANADA"); ..... .. } C++Prog
No. You will need a
CListBox
control variable (use ClassWizard for this), then callAddString()
in the context of that variable.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
if the content is static ( will be filled once with constant values ) then, you can add them directly in the resource editor ( no code needed for that ). if the contenct is dynamic, you can use
CListBox::AddString
orCListBox::InsertString
( you need to code this ).
Maximilien Lincourt Your Head A Splode - Strong Bad
Thanks for your reply. Yes, the content is Static. Can you please give me some idea how to add this in resource editor. Thanks Once Again MFC
-
No. You will need a
CListBox
control variable (use ClassWizard for this), then callAddString()
in the context of that variable.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
O okay, Thanks...I got it. Thanks once again MFC
-
Thanks for your reply. Yes, the content is Static. Can you please give me some idea how to add this in resource editor. Thanks Once Again MFC
Preeti9 wrote:
Yes, the content is Static. Can you please give me some idea how to add this in resource editor.
While it might be considered a neat idea, this solution has many drawbacks. In fact, it is only useful if the items in the control are language independent, and are insensitive to sorting.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Preeti9 wrote:
Yes, the content is Static. Can you please give me some idea how to add this in resource editor.
While it might be considered a neat idea, this solution has many drawbacks. In fact, it is only useful if the items in the control are language independent, and are insensitive to sorting.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
Hmmm, Thanks I got it. MFC
-
Hi All, I am creating a list box with multiple selection at a time. I would appreciate if someone let me know how to add items in LIST BOX using MFC. For example: I need to add USA, CANADA, MEXICO, ENGLAND, INDIA, CHINA in my list. How to add these itmes? Do I need to write code or just can do it other way? Thanks in advance MFC
Like this CListBox m_List; m_List.AddString("123"); m_List.InsertString(1,"2323");