CListBox::AddString This method adds a string to a list box. If the list box was not created with the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted. If the list box was created with the LBS_SORT style but not the LBS_HASSTRINGS style, the framework sorts the list by one or more calls to the CompareItem method.int AddString( LPCTSTR lpszItem ); Parameters lpszItem Points to the null-terminated string that is to be added. Return Value The zero-based index to the string in the list box. The return value is LB_ERR if an error occurs; the return value is LB_ERRSPACE if insufficient space is available to store the new string.Use InsertString to insert a string into a specific location within the list box.Example // The pointer to my list box. extern CListBox* pmyListBox;// Add 10 items to the list box. CString str; for (int i=0;i < 10;i++) { str.Format(_T("item string %d"), i); pmyListBox->AddString( str ); }//不会了先查MSDN
CString csDValue;
csDValue.Format(_T("%f"), dValue);
listbox.AddString(csDValue);
This method adds a string to a list box. If the list box was not created with the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted. If the list box was created with the LBS_SORT style but not the LBS_HASSTRINGS style, the framework sorts the list by one or more calls to the CompareItem method.int AddString(
LPCTSTR lpszItem );
Parameters
lpszItem
Points to the null-terminated string that is to be added.
Return Value
The zero-based index to the string in the list box. The return value is LB_ERR if an error occurs; the return value is LB_ERRSPACE if insufficient space is available to store the new string.Use InsertString to insert a string into a specific location within the list box.Example
// The pointer to my list box.
extern CListBox* pmyListBox;// Add 10 items to the list box.
CString str;
for (int i=0;i < 10;i++)
{
str.Format(_T("item string %d"), i);
pmyListBox->AddString( str );
}//不会了先查MSDN
str.Format(_T("item string %d"), i);这个的%i改成%lf或者%f,i为double类型的变量