Bas*_*ien 2 c++ wxwidgets wxtextctrl
我正在与我的 wxTextCtrl 解决一个烦人的问题。无论我尝试什么,都无法添加新行。wxTextCtrl 显示一个方形字符而不是一个新行。
这是相关的代码:
wxTextCtrl * detail = new wxTextCtrl (this,wxID_ANY);
detail->SetWindowStyle(wxTE_MULTILINE);
detail->SetEditable(false);
detail->AppendText("Some text");
detail->AppendText("\n New line");
detail->AppendText("\n An other new line\n");
detail->AppendText("Again a new line");
Run Code Online (Sandbox Code Playgroud)
我得到:
一些文字◻◻换行◻◻换行◻◻换行◻◻再换行
首先我认为Multiline属性有问题但detail->IsMultiLine()返回true
任何帮助将不胜感激,
构造对象时必须指定 Multiline 属性。之后就不能设置了。
从 wxWidgets 文档中它特别提到了这一点:
Note that alignment styles (wxTE_LEFT, wxTE_CENTRE and wxTE_RIGHT) can be changed dynamically after control creation on wxMSW and wxGTK. wxTE_READONLY, wxTE_PASSWORD and wrapping styles can be dynamically changed under wxGTK but not wxMSW. The other styles can be only set during control creation.
代替:
detail->SetWindowStyle(wxTE_MULTILINE);
Run Code Online (Sandbox Code Playgroud)
这应该有效:
wxTextCtrl(this,wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
Run Code Online (Sandbox Code Playgroud)