c# - 在 C# 中将图像添加到面板
问题描述
我正在尝试将音乐笔记的图像添加到已经存在的面板中。我已经为图像创建了路径:
String NoteImage_path = Environment.CurrentDirectory + @"\Notes-Images\";
我尝试使用以下代码行将图像添加到面板:
this.panel2.Controls.Add(this.NoteImage_path);
但我无法将字符串转换为 System.Windows.Form.Control。
我该如何解决这个问题?任何帮助将不胜感激。谢谢!
解决方案
设置面板的背景图片
panel2.BackgroundImage = Image.FromFile(NoteImage_path);
推荐阅读
- html - 如何在 HTML 中缩进列表
- r - autoarima 训练和测试,在 r 中按 id 分组
- javascript - 在Javascript / Jquery中自动选中复选框时发出警报
- javascript - 从 module2.js 调用 nodejs module1.js 然后解析一些变量
- r - rjags:节点 x 中的错误,节点与父节点不一致 - R 4.0.0 中的逻辑回归“李斯特包”
- javascript - Google 表格函数 importJSON 在新列中返回对象
- blazor - 在我的自定义选择 blazor 组件中进行选择时的回调
- asp.net-mvc - 将数据从视图模型传递到控制器
- c# - MailMerge - Excel(数据)到 Word(模板) - 使用 OpenXML
- python - 如何在 django 数据库中检索数据作为列表