C#打开并编辑表单.......... [英] C# Open and edit a form.............

查看:68
本文介绍了C#打开并编辑表单..........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何打开表格,但是当我打开表格时如何编辑?就像有一个其他形式的图片框,我想在打开它时更改它的背景色

例如

I know how to open a form but how do i edit it when i open it? like there is a picturebox in the other form and i want to change the backcolor of it when its opened

eg

form2 newform2 = new form2();
newform2.show();

// this part here is my preoblem, how do i make it so it will change, like right now its not giving me the option

picturebox1.backcolor = color.green;

推荐答案

您可以使用可接受背景色的版本重载Form2构造函数:

You could overload the Form2 constructor with a version that accepts the desired background color:

public Form2(Color background)
{
    InitializeComponent();
    if (background != null)
    {
        pictureBox1.BackColor = background;
    }
}



然后执行以下操作:



and then do this:

Form2 forum2 = new Form2(Colors.Green);




在您的主窗体中处理form2的Load事件.
在此方法中,为处理程序分配的Main表单做任何您想做的事情.

希望对您有帮助.

问候
AR
Hi,

Handle the Load event of form2 in your main form.
Do whatever you want to do with Main form in this method which assigned with handler.

Hope it will help you.

Regards
AR


form2 newform2 = new form2();
newform2.show();

//here you are changing the background color of a picture box
//stored in THIS form: NOT form2!!
picturebox1.backcolor = color.green;



您参加过这样的活动吗?



Did you attend somethign like this?

form2 newform2 = new form2();
newform2.Show();
newform2.picturebox1.BackColor = Color.Green;


这篇关于C#打开并编辑表单..........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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