C++ 9 :: 转换“System::Object ^ sender”控制类型
这次在 C++ 9 (VS2008) 中,我尝试将“System::Object ^ sender”强制转换为其表示的 Control 类型。
这具体是在 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
欢迎任何想法。
谢谢!
This time in C++ 9 (VS2008) I am attempting to cast a "System::Object ^ sender" to the Control type that it represents.
This is specifically in a TextBox_TextChanged event function.
I know this works fine in C# but I'm getting errors when I try it in C++ and I can't seem to find the equivalent for C++.
C++ Code that is giving me errors . . .
System::Void txtEmplNum_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
TextBox thisBox = sender as TextBox ;
}
And the error that results . . .
Error 1 error C2582: 'operator =' function is unavailable in 'System::Windows::Forms::TextBox' c:\projects\nms\badgescan\frmMain.h 673 BadgeScan
Any ideas are welcome.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你可能想尝试这个:
I think you might want to try this:
您上面提供的代码不是 C++。 C++没有“as”关键字;对于 C++,该方法编写正确,但代码块错误。
The code you provided above is not C++. C++ has no "as" keyword; The method is written correctly for c++ but the code block is wrong.