Doing a C++ GUI for extra credit, I want the user to input his/her age and output a result depending on the result.
1 2 3 4 5 6
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if (comboBox1->Text == "0")
{
label2->Text = System::Convert::ToString(("You are still a baby"));
label2->Text = System::Convert::ToString(("Keep on developing"));
}
The problem is only "Keep on developing" is showing whenever 0 is inputted how do I show both "You are still a baby" & "Keep on developing" when 0 is inputted?
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if (comboBox1->Text == "0")
{
label2->Text = System::Convert::ToString(("You are still a baby. Keep on developing."));
}
this looks more like c#
but anyways, why have 2 lines of string returns of the same caller, where you can have them combined into 1
theyre both inside the "0" anyways
only "keep on developing" is showing because it's the last duplicate line so it replaces whatever is on top of it
What if I want to show it on different text lines? for example.
You are still a baby // 1st line
Keep on developing// 2nd line
Basically, what I'm looking for, the best way I think my beginner brain can say is, when using a GUI is there an endl; version?
@jvlinh I'm gonna be honest our prof. is not going to teach us GUI and I'm doing it with mostly the help of this website and a lot of youtube. Also, I already did a normal C++ program for what I'm trying to do and it works just fine, the Windows Form is where I'm struggling to find tutorials and help
@keskiverto I'm sorry but I kinda don't understand the question? (we haven't discussed strings yet and I'm swimming blindly doing this GUI)
A GUI label is not a stream. It is an object that has a string member and the value of that member is rendered on display.
We assign a value to label1->Text. The value is an array of characters. We can have newline characters in the array.
It is possible that some GUI objects (like edit box) do not render multiline text content. One can get around that by having more label objects, but that might complicate layout management.