更改表单的背景色,在C#中使用颜色对话框更改多个表单? [英] changing backcolor of a form,multiple forms using color dialog in C#?
本文介绍了更改表单的背景色,在C#中使用颜色对话框更改多个表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想单击颜色对话框即可更改表单的所有背景色.我该怎么办?
在此先感谢=)
i want to change all backcolor of my forms in just i click of color dialog. how would i do that?
thanks in advance =)
推荐答案
我认为更改表单背景色的目的可能是针对不同的主题,在这种情况下,以下文章可能对您有用
精美的Windows表单 [
I think the purpose of changing the backcolor of forms may be for different themes, in which case the following article may be useful to you
Fancy Windows Forms[^]
If you problem is solved you may accept and vote the solution, otherwise please post your queries
PES
只需尝试一下..
just try this..
colorDialog1.ShowDialog();
this.BackColor = colorDialog1.Color;
这是将底色应用于项目中所有表单的方法.
This is how you can apply backcolor to all forms within your project.
using System.Reflection;
private void btnChangeFormColor(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
Color backcolor = colorDialog1.Color;
//Get all Forms within the project
Type[] AllTypesInProjects = Assembly.GetExecutingAssembly().GetTypes();
for(int i=0;i<AllTypesInProjects.Length;i++)
{
if (AllTypesInProjects[i].BaseType == typeof(Form))
{
/* Convert Type to Object */
Form f = (Form)Activator.CreateInstance(AllTypesInProjects[i]);
f.BackColor = backcolor;
}
}
}
在项目中获取所有表格的来源:
http://codeindex.blogspot.in/2011/11/get-list-of-all-forms-in-project-using.html [
}
Source for getting all forms within project:
http://codeindex.blogspot.in/2011/11/get-list-of-all-forms-in-project-using.html[^]
这篇关于更改表单的背景色,在C#中使用颜色对话框更改多个表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文