这次在 C++ 9 (VS2008) 中,我试图将“System::Object ^ sender”转换为它所代表的控件类型。
这具体在 TextBox_TextChanged 事件函数中。
我知道这在 C# 中运行良好,但在 C++ 中尝试时出现错误,而且我似乎找不到 C++ 的等效项。
给我错误的 C++ 代码。 . .
System::Void txtEmplNum_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
TextBox thisBox = sender as TextBox ;
}
以及由此产生的错误。 . .
Error 1 error C2582: 'operator =' function is unavailable in 'System::Windows::Forms::TextBox' c:\projects\nms\badgescan\frmMain.h 673 BadgeScan
欢迎提出任何想法。
谢谢!
最佳答案
我想你可能想试试这个:
System::Void txtEmplNum_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
TextBox^ thisBox = safe_cast<TextBox^>(sender);
}
关于visual-studio-2008 - C++ 9::将 "System::Object ^ sender"转换为控件类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4316677/