A set of .NET Framework managed libraries for developing graphical user interfaces.
was using incorrect syntax: changed to textBox1->Clear(); and it's working
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Learning Visual C++ using Win Forms and VS 2019. Created a Win Forms with two textboxes and a single button. texbox1 is an input box and textbox2 echoes text box1 input. When button is clicked, I want the event to clear textbox1 using the Clear() method. Code snippet below. Problem is that Clear() is a method of TextBoxBase class and not TextBox class. I thought that TextBox class in inherited TextBoxBase class and I could simply use textBox1.Clear() because textBox1 is an object of TextBox class but that is not correct. Would appreciate any help. Thank you
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
textBox1.Clear();
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
textBox2->Text = textBox1->Text;
}
A set of .NET Framework managed libraries for developing graphical user interfaces.
was using incorrect syntax: changed to textBox1->Clear(); and it's working