从自定义控制面板中更改运行形式的BackgroundImage [英] Change BackgroundImage of form from Custom Control running in Panel

查看:176
本文介绍了从自定义控制面板中更改运行形式的BackgroundImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目包含与包含自定义控制面板的一种形式。
在此自定义控件我有一个更改背景图片的按钮。

My project consists of a form with a panel that contains a custom control. In this custom control I have buttons that change the background image.

我的问题是;这些按钮只改变它们放置在自定义控件的背景图像,我需要他们改变包含与自定义的控制面板中的主窗体的背景图像。

My issue is; these buttons only change the background image of the custom control that they are placed in, and I need them to change the background image of the main form containing the panel with the custom control.

我目前的code:

this.BackgroundImage = Image.FromFile(System.IO.File.ReadAllText(BackgroundSkinsPath));

我需要的东西,实际上将做到这一点:

I need something that will in effect accomplish this:

MainForm.BackgroundImage = Image.FromFile(System.IO.File.ReadAllText(BackgroundSkinsPath));

即:从 CustomControl.cs

推荐答案

我最终使用不同的东西:

I ended up using something different:

Form MainForm = Application.OpenForms["(The name of the form in which I wanted to change the background)"];

//...

MainForm.BackgroundImage = Image.FromFile(System.IO.File.ReadAllText(BackgroundSkinsPath));

它结束了比我还以为它是简单了很多。

It ended up being a lot simpler than I thought it was.

这篇关于从自定义控制面板中更改运行形式的BackgroundImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆