我在一个基于对话框的应用程序中,准备使用EDIT控件作为文本的显示框。我起初是想用ReplaceSel()但是他的参数表里只能加字符型的数组,我给数组赋值的时候无法将换行符'\t'或者endl赋给它,是不是换行符不用这两个啊?而且我发现,给数组一个一个赋值,输出的时候总是有错。有没有其他的办法输出文本呢?我在做一个基于对话框的小程序。EDIT控件里要输出数据列表,就像职工列表一样,有没有什么其他的办法呢?由于这个程序很急,如果有那位能够相助,我感激不尽。(麻烦说详细一点)

解决方案 »

  1.   

    我的方法不一定好,但是能实现。
    我也做了一个数组,然后位Edit控件定义一个CString str1的变量,然后再定义一个CString str2的变量。首先做一个循环,每次从数组里面读一个数,并把它转换成字符串类幸赋给str2,然后通过调用CString中的Insert函数,把它插入str1的末尾,在循环中,需要换行的时候,就在插入\r\n就可以了。
    最后一起输出!!!
      

  2.   

    Call this function to set the inclusion of soft line-break characters on or off within a multiple-line edit control.BOOL FmtLines(
       BOOL bAddEOL 
    );
    Parameters
    bAddEOL 
    Specifies whether soft line-break characters are to be inserted. A value of TRUE inserts the characters; a value of FALSE removes them. 
    Return Value
    Nonzero if any formatting occurs; otherwise 0.Res
    A soft line break consists of two carriage returns and a linefeed inserted at the end of a line that is broken because of word wrapping. A hard line break consists of one carriage return and a linefeed. Lines that end with a hard line break are not affected by FmtLines. Windows will only respond if the CEdit object is a multiple-line edit control. FmtLines only affects the buffer returned by GetHandle and the text returned by WM_GETTEXT. It has no impact on the display of the text within the edit control.For more information, see EM_FMTLINES in the Platform SDK.Example
    #ifdef _DEBUG
       // The pointer to my edit.
       extern CEdit* pmyEdit;
       CString strText;   // Add soft line-break breaks.
       pmyEdit->FmtLines(TRUE);   // Dump the text of the edit control.
       pmyEdit->GetWindowText(strText);
       afxDump << strText;   // Remove soft line-break breaks.
       pmyEdit->FmtLines(FALSE);
    #endif