2 years ago
#65227

Coakey
C++ WinForms, get the name of a System object
I'm currently learning how to make windows programs in C++ with CLR in Visual Studio 2022. I'm very new to C++ (Started 2 days ago and I barely know what a struct is), and I just can't seem to find out how I can get the name of an object (A label) on my form as a string variable to log to the developer's console.
Here's my current code:
private:
System::Void Btn1_Click(System::Object^ sender, System::EventArgs^ e)
{
string label1name = label1->AccessibleName->ToString();
string label1text = label1->Text->ToString();
cout << "[INPUT] " << "Was pressed" << endl;
cout << "[DEBUG] Changed " << label1name << " to " << label1text << endl;
}
and here's a screenshot of my current form: Windows form screenshot
windows
winforms
c++-cli
clr
visual-studio-2022
0 Answers
Your Answer