How would I write a program that writes the text in a textbox to a List Box when a button is pressed, kind of like an address book?

Recommended Answers

All 6 Replies

Depends on what you are programming? *nix? MS-Windows? QT? there are lots of others too. You need to be a lot more specific about what you are coding.

Right now I am working in visual C++. I have my gui set up with a textbox, button, and list box, but I'm not sure what code I have to write to get the program to work as I want it to.

you are still not specific enough. Do you have a win32 program or c++/CLI Windows Forms program?

Windows Forms

Activate the ListBox's SelectedIndexChanged event (use listBox's properties window to do that) and the IDE will generate a function for you, then just do this:

private: System::Void listBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
				 textBox1->Text = listBox1->Text;
			 }

Thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.