【发布时间】:2018-05-16 17:01:45
【问题描述】:
我正在处理一段遗留代码,我正在尝试更新一些界面。我不精通 C++/CLI,C++/CLI 的文档充其量也很少。我尽我所能将 C# 文档转换为 C++/CLI,但它并不总是有效。
我想将 System::Object 转换为 ContextMenuStrip。
示例代码是:
System::Void Form1::unzoomToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
System::Windows::Forms::ContextMenuStrip ^menu = sender;
//a value of type "System::Object ^" cannot be used to initialize and entity of type "System::Windows::Forms::ContextMenuStrip ^"
//Other code here
}
这是如何在 C++/CLI 中完成的?
【问题讨论】:
-
你可以试试下面的
auto menu = (System::Windows::Forms::ContextMenuStrip ^)sender;。
标签: c++-cli