gpt4 book ai didi

c# - 如何从 C# 中的资源文件设置面板的背景图像?

转载 作者:行者123 更新时间:2023-11-30 13:26:55 27 4
gpt4 key购买 nike

我想在 C# 中更改面板的背景图像 Windows Forms应用。我要设置为背景的图像位于 Solution Explorer 中的资源文件夹中.如何在代码中使用它?

我试过这个:

panel1.BackgroundImage = Properties.Resources.Chalkboard; 

但是没有用。

最佳答案

我试过和你一样的代码,当我点击一个按钮时它工作正常。

private void pnlBgBtn_Click(object sender, EventArgs e)
{
panel1.BackgroundImage = Properties.Resources.image;
}

“Properties.Resources.image”中的名称“image”应该是您为图像指定的名称。图像的正确名称应该是项目属性下project-proje 中显示的名称。

关于c# - 如何从 C# 中的资源文件设置面板的背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16387302/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com