请教一下各位高手,如何在列表框当中显示非CString类的数据?比如如何显示整型或者浮点型数据?

解决方案 »

  1.   

    CString str;
    str.Format("%d",123);
    str.Format("%f",3.14);
      

  2.   

    将整型和浮点形的数据转换为字符串
    int a;
    float b;
    char str[20];
    sprintf(str,"%d%f",a,b);
      

  3.   

    对啊.转换成CString就是了
    有三种方法
    1. C语言的方法
    #include <stdio.h>
    ...
    int x=100;
    char str[30];
    itoa(100,x);
    2. C语言方法
    #include <stdio.h>
    ...
    int x=100;
    float x2=1.11111;
    char str[30];
    sprintf(m,"%f",x2);
    或sprintf(m,"%d",x);
    整数对应%d,浮点小数对应%f3.MFC中的方法
    就是 qiushuiwuhen(秋水无恨) 说的
    CString str;
    str.Format("%d",123);
    str.Format("%f",3.14);
      

  4.   

    可以格式化数据吗
    就如楼上几位所说的那样
    CString str;
    str.Format("%d",123);
    str.Format("%f",3.14);: tangl_99(Min-Kyeong) ( 已经讲得够狗详细了