简体   繁体   English

wxTextCtrl新行问题

[英]wxTextCtrl new line issues

I'm fighting against an anoying problem with my wxTextCtrl. 我正在用我的wxTextCtrl来解决一个恼人的问题。 Whatever I try, there is no way to add a new line. 无论我尝试什么,都无法添加新线。 wxTextCtrl diplay a square character instead of a new line. wxTextCtrl显示一个方形字符而不是一个新行。
Here is the relevant code : 这是相关代码:

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");  

And i get : 我得到:

Some text◻◻New line◻◻An other new line◻◻Again a new line 一些文字◻◻新线◻◻另一条新线◻◻再换一条线

First I thought there was a problem with the Multiline property but detail->IsMultiLine() return true 首先我认为Multiline属性存在问题,但detail->IsMultiLine()返回true

any help will be appreciated, 任何帮助将不胜感激,

You must specify the Multiline property when you constrcut the object. 在构造对象时必须指定Multiline属性。 You can not set this afterwards. 之后您无法设置此项。

From the wxWidgets documentation it mentions this specifically: 从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.

Instead of: 代替:

detail->SetWindowStyle(wxTE_MULTILINE);

this should work: 这应该工作:

wxTextCtrl(this,wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM