wxWidget newbie, trouble w/ multiline

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Buttshark69
In need of some credit
In need of some credit
Posts: 1
Joined: Mon Mar 11, 2019 5:20 pm

wxWidget newbie, trouble w/ multiline

Post by Buttshark69 »

Hello, Im new to wxWidgets and C++,
our class was originally learning C languge with console, and our prof. suddenly decides
it's a good idea to shift to C++ and Wxwidgets without a warning then gave a very few
examples (basics of the basics) and immediately gave us Laboratory Activities to do.
-------------------------------------------------------------------------------------------------------------

We were only shown that to Output a result, you should use SetValue();

The SetValue only displays the last %s, which is textbox3 and I cant find how to
output all 3 strings in the resultbox.

Code: Select all

wxString textbox1;
wxString textbox2;
wxString textbox3;

textbox1= firstbox->getvalue();
textbox2= secondbox->getvalue();
textbox3= thirdbox->getvalue();

resultbox->SetValue(("%s \n %s \n %s", textbox1, textbox2, textbox3));
The multi-line option in the resultbox((wxEdit box)) is already "True".

We were suppose to get the strings on first to third box then output them as seen below in the "resultbox" in multiple lines.

Code: Select all

String in firstbox.
String in secondbox.
String in thirdbox.
What function do I use to obtain the output above in multiple lines in wxwidget?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidget newbie, trouble w/ multiline

Post by doublemax »

First of all: Is the wxTextCtrl high enough, so you can see multiple lines?

Code: Select all

resultbox->SetValue(("%s \n %s \n %s", textbox1, textbox2, textbox3));
This should be:

Code: Select all

resultbox->SetValue( wxString::Format("%s \n %s \n %s", textbox1, textbox2, textbox3) );
Use the source, Luke!
Post Reply