我要在视图中显示这样的格式,请问如何做比较好?面积     高     宽     周长
500      50     10     120
10       2      5      14
......数据长度不同,最好能与标题对齐,能说得详细点、给出代码最好!
谢谢!   

解决方案 »

  1.   

    strText.Format("%10x%10x%10x%10x", s, h, w, c);
    pDC->TextOut(strText);
    %10x,里面的10就是由你自己定的!
      

  2.   

    int DrawText(
      HDC hDC,          // handle to device context
      LPCTSTR lpString, // pointer to string to draw
      int nCount,       // string length, in characters
      LPRECT lpRect,    // pointer to struct with formatting dimensions
      UINT uFormat      // text-drawing flags
    );
     Call this member function to format text in the given rectangle.
     看msdn
      

  3.   

    CSize TabbedTextOut( int x, int y, const CString& str, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin );Call this member function to write a character string at the specified location, expanding tabs to the values specified in the array of tab-stop positions
      

  4.   

    首先要把字体设成等宽字体,那么你就能用
    strText.Format("%10x%10x%10x%10x", s, h, w, c);
    简单搞定;
    否则你就必须计算纵横坐标,逐一调用TextOut输出。
      

  5.   

    同意楼上的,字体要等宽。如Courier New。
    然后在按相同宽度的格式在同一横坐标输出。