创建一个像这样的多种形式 [英] create multi form like one from

查看:54
本文介绍了创建一个像这样的多种形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

如何创建用于创建其他类似示例的示例表单?

我的意思是:创建一个具有特殊颜色,大小,方向和...的表格,然后从中创建其他表格...

但是当我创建所有表单时....如果主表单发生了更改...其他表单没有发生变化

请帮助我...

非常感谢...

Hi All

how do i create Sample Form For Create Other Like That ?

I Mean : Create One Form With Special Color , Size , Direction and ... And Create Other Form From It ...

But When I Create All Forms .... If Main Form Change ...Other Form Not Change

Please Help ME ...

Thanks A lot ...

推荐答案

这不是那么简单,但是...

我会怎么做.
创建一个名为Theme的类.
将其设置为静态或单例.
在主题中,创建一个Color属性.
在主题中,创建事件已更改"
在每个您要使用主题的窗口中,从构造函数中插入更改后的事件
在事件处理程序中,使用主题中的Color属性.

It''s not that simple, but...

How I would do it.
Create a class called Theme.
Make it static or Singleton.
In the Theme, create a Color property.
In the Theme, create an event "Changed"
In each window you wish to use the theme, hook into the changed event from the constructor
In the event handler, use the Color property from the Theme.

private static Color color = Color.Red;
public static Color Color
    {
    get { return color; }
    set
        {
        color = value;
        OnChanged(null);
        }
    }

public static event EventHandler Changed;

private static void OnChanged(EventArgs e)
    {
    EventHandler eh = Changed;
    if (eh != null)
        {
        eh(null, e);
        }
    }





public Form1()
    {
    InitializeComponent();
    Theme.Changed += new EventHandler(Theme_Changed);
    }

void Theme_Changed(object sender, EventArgs e)
    {
    BackColor = Theme.Color;
    }


这篇关于创建一个像这样的多种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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