"\n" doesn't not work on windows ? Topic is solved
"\n" doesn't not work on windows ?
Hey !
I am building a wxTreeCtrl and i would like that some of the item to be on multiple line.
So i use "\n" in the wxString i want to be on multiple line.
It works perfectly on linux but on windows it just ignore the "\n". For example "test\ntest" becomes "testtest".
So did i do something wrong or is this normal ? Is there any workaround ?
Thanks for your help.
I am building a wxTreeCtrl and i would like that some of the item to be on multiple line.
So i use "\n" in the wxString i want to be on multiple line.
It works perfectly on linux but on windows it just ignore the "\n". For example "test\ntest" becomes "testtest".
So did i do something wrong or is this normal ? Is there any workaround ?
Thanks for your help.
Re: "\n" doesn't not work on windows ?
Perhaps the native undlerlying control on MSW (tree view) does not support multiline text of its nodes?
Re: "\n" doesn't not work on windows ?
I don't know. In this case i would like to know if there is an other way to do what i want.
Re: "\n" doesn't not work on windows ?
Maeglix wrote:Hey !
I am building a wxTreeCtrl and i would like that some of the item to be on multiple line.
So i use "\n" in the wxString i want to be on multiple line.
It works perfectly on linux but on windows it just ignore the "\n". For example "test\ntest" becomes "testtest".
So did i do something wrong or is this normal ? Is there any workaround ?
Thanks for your help.
You can try to use "\r\n"
"\n" should be valid on the command line
Re: "\n" doesn't not work on windows ?
I tried, it didn't work.
Re: "\n" doesn't not work on windows ?
Altough i couldn't find any "official" confirmation on MSDN, i'm pretty sure this is the case. I can't remember to have ever seen a multi-line text in a standard tree control under Windows.PB wrote:Perhaps the native undlerlying control on MSW (tree view) does not support multiline text of its nodes?
Use the source, Luke!
Re: "\n" doesn't not work on windows ?
Ok thank you so i will try to find another way.
-
- Super wx Problem Solver
- Posts: 469
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
Re: "\n" doesn't not work on windows ?
Maybe the generic tree control would work. I don't remember how to use it on windows though.Maeglix wrote:Ok thank you so i will try to find another way.
Re: "\n" doesn't not work on windows ?
wxGenericTreeCtrl does not properly support multiline node labels either (they overlap).
wxDataViewTreeCtrl does not seem to support the feature too but I never used the class so I may have not used it properly
Code: Select all
#include <wx/wx.h>
#include <wx/treectrl.h>
#include <wx/generic/treectlg.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(NULL, wxID_ANY, _("Test"))
{
wxGenericTreeCtrl* ctrl = new wxGenericTreeCtrl(this, wxID_ANY);
ctrl->AddRoot("Root\r\nLine2");
ctrl->AppendItem(ctrl->GetRootItem(), "Item 1\r\nLine2");
ctrl->AppendItem(ctrl->GetRootItem(), "Item 2\r\nLine2");
ctrl->ExpandAll();
}
};
class MyApp : public wxApp
{
public:
bool OnInit()
{
(new MyFrame())->Show();
return true;
}
}; wxIMPLEMENT_APP(MyApp);
Code: Select all
#include <wx/wx.h>
#include <wx/dataview.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(NULL, wxID_ANY, _("Test"), wxDefaultPosition, wxSize(200,200))
{
wxDataViewTreeCtrl* treeCtrl = new wxDataViewTreeCtrl(this, wxID_ANY);
wxDataViewItem rootItem = treeCtrl->AppendItem(wxDataViewItem(0), "Root\nLine2");
}
};
class MyApp : public wxApp
{
public:
bool OnInit()
{
(new MyFrame())->Show();
return true;
}
}; wxIMPLEMENT_APP(MyApp);