How can i Add a set of integers to my ComboBox
-
hi, I've added a set of strings(from Database) to my combo box using membervariable.AddString(CString) Now,How can i add a set of integers to my combo box. Can any one tell mi a solution for this...with a clear example(as i'm a beginner). if so please tell me how to add the floats to the same.. thank you in advance..........
-
hi, I've added a set of strings(from Database) to my combo box using membervariable.AddString(CString) Now,How can i add a set of integers to my combo box. Can any one tell mi a solution for this...with a clear example(as i'm a beginner). if so please tell me how to add the floats to the same.. thank you in advance..........
You can convert your numeric types to strings...
int i = 42;
CString str;
str.Format(_T("%d"), i);
m_combobox.AddString(str);double d = 1.23456;
CString str;
str.Format(_T("%.3f"), d); // rounded to 3 decimal places
m_combobox.AddString(str);Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You can convert your numeric types to strings...
int i = 42;
CString str;
str.Format(_T("%d"), i);
m_combobox.AddString(str);double d = 1.23456;
CString str;
str.Format(_T("%.3f"), d); // rounded to 3 decimal places
m_combobox.AddString(str);Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
hai mark, even i wanted to suggest the same,but before hitting reply, i saw your name ,got diverted towards your post, and dropped my idea. your post is more descriptive.
Mark Salsbery wrote:
str.Format(_T("%d"), i);
can you please explain me why you have used _T there. thank you.
Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.
-
hai mark, even i wanted to suggest the same,but before hitting reply, i saw your name ,got diverted towards your post, and dropped my idea. your post is more descriptive.
Mark Salsbery wrote:
str.Format(_T("%d"), i);
can you please explain me why you have used _T there. thank you.
Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.
chandu004 wrote:
can you please explain me why you have used _T there.
I use the generic text mappings everywhere. In this case, I'm using a CString, which is a generic type (unlike CStringA and CStringW). CString::Format() takes a PCXSTR as its first argument so I use _T() to get that type. This will compile on both Unicode and non-Unicode builds... that's the whole idea :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
hai mark, even i wanted to suggest the same,but before hitting reply, i saw your name ,got diverted towards your post, and dropped my idea. your post is more descriptive.
Mark Salsbery wrote:
str.Format(_T("%d"), i);
can you please explain me why you have used _T there. thank you.
Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.
Some reference material... Using Generic-Text Mappings (CRT)[^]
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Some reference material... Using Generic-Text Mappings (CRT)[^]
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
thanks mark. i feel that, observing your posts one day is equalent to reading one book per day.:) :rolleyes:
Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.
Of course sometime forums are better than books like this forum.