Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2008 C++;9.“铸造”;系统::对象^sender“;控制类型 这个时间在C++ 9(VS2008)中,我试图将一个“St::ObjyTever”转换为它所代表的控制类型。_Visual Studio 2008_Textbox_C++ Cli - Fatal编程技术网

Visual studio 2008 C++;9.“铸造”;系统::对象^sender“;控制类型 这个时间在C++ 9(VS2008)中,我试图将一个“St::ObjyTever”转换为它所代表的控制类型。

Visual studio 2008 C++;9.“铸造”;系统::对象^sender“;控制类型 这个时间在C++ 9(VS2008)中,我试图将一个“St::ObjyTever”转换为它所代表的控制类型。,visual-studio-2008,textbox,c++-cli,Visual Studio 2008,Textbox,C++ Cli,这在TextBox\u TextChanged事件函数中特别有用 我知道这在C++中是很好的,但是我在C++中尝试时会出错,而且我似乎找不到C++的等价性。 给我错误的C++代码 System::Void txtEmplNum_TextChanged(System::Object^ sender, System::EventArgs^ e) { TextBox thisBox = sender as TextBox ; } 以及由此产生的错误 Error 1 error C

这在TextBox\u 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); 
} 
System::Void txtempnum\u TextChanged(System::Object^sender,System::EventArgs^e)
{ 
TextBox^thisBox=safe\u cast(发送方);
} 

<代码> >您上面提供的代码不是C++。C++没有“AS”关键字;该方法是为C++编写的,但代码块是错误的。
System::Void txtEmplNum_TextChanged(System::Object^  sender, System::EventArgs^  e)
{
    // This is not C++.
    TextBox thisBox = sender as TextBox;

    // This is C++ as already stated above.
    TextBox^ tb = safe_cast<TextBox^>(sender);

    // Or you can just do this if you don't need a handle beyond
    // this line of code and just want to access a property or a method.
    safe_cast<TextBox^>(sender)->Text = "Some Text";
}
System::Void txtempnum\u TextChanged(System::Object^sender,System::EventArgs^e)
{
//这不是C++。
TextBox thisBox=发送者作为TextBox;
//这是上面已经说过的C++。
文本框^tb=安全模式(发送方);
//或者,如果你不需要把手,你也可以这样做
//这是一行代码,只想访问属性或方法。
safe_cast(发送者)->Text=“Some Text”;
}