c++ - 不允许使用 Visual Studio 图像类型
问题描述
我正在尝试根据单击更改图像(Visual Studio C++)。我的代码:
private: System::Void FirstChannelButton_Click_1(System::Object^ sender, System::EventArgs^ e) {
FirstChannelButton->Image = Image.FromFile("C:\Users\Username\source\repos\Project\ChOne.png");
}
与该人在这里尝试做的事情完全相同 C++ Change image based on a click (Visual Studio C++)
但我得到错误:不允许类型名称和'System::Drawing::Image':非法使用这种类型作为表达式。
解决方案
FromFile
is a static method and C++ /CLI syntax requires to use ::
for static method calls. So in this case the call should look next:
FirstChannelButton->Image = Image::FromFile("...")
推荐阅读
- jquery - jquery识别页面具有多个表单的表单
- angular - 如何从 api 获取 JSON 数组对象值?
- python - SAS 与 Python
- css - CSS:在模态中打印长 div,在 IE 中没有第二页
- sed - 如何使用 echo tail 创建大文件的子集
- python - 从 Lotus Notes 视图获取数据的有效方法
- r - 如何在 R 中为函数使用条件语句和返回值?
- c# - WPF / C#:通过按钮从 DataGrid 中的 List<> 中删除项目
- asp.net-mvc - NOT FOUND - 服务器没有找到与请求的 URI 匹配的任何内容
- thymeleaf - 有没有办法在没有 th:insert 的情况下评估片段中的变量