本节内容:
asp.net获取颜色值的方法
 
1,如何将电脑中可用字体加入winform中的combobox中: 
 
复制代码 代码示例:
combobox1.items.addrange (fontfamily.families);
2,取得所有可用颜色并填充到asp.net的下拉菜单中: 
 
复制代码 代码示例:
propertyinfo[] properties; 
arraylist colors; 
color color; 
// solidbrush brush; 
properties = typeof (color).getproperties (bindingflags.public | bindingflags.static); 
colors = new arraylist (); 
foreach (propertyinfo prop in properties) 
{ 
// get the value of this static property 
color = (color) prop.getvalue (null, null); 
// skip colors that are not interesting 
if (color == color.transparent) 
continue; 
if (color == color.empty) continue; 
try 
{ 
ddllist.items.add(prop.name); 
} 
catch 
{ 
} 
// create a solid brush of this color 
//brush = new solidbrush (color); 
//colors.add (brush); 
}
3,如何取得数据库的连接字符串? 
a,新建一个文本文件,文件名使用*.udl(比如:mydb.udl),此时发现图标变成数据库连接的图标了。 
b,双击此文件,弹出数据连接属性的对话框,此时你可以进行设置了。
一般首先选择“提供程序”的选项卡,进行设置之后,再设置“连接”选项卡的相关属性,其他的我就不说了。
设置好之后,最后按“确定”。可能会有相应的提示,比较好解决,根据情况自己确定。 
c,用记事本打开刚才的这个文件。
其中有类似这样的字符串: 
provider=sqloledb.1;password=123456sa;persist security info=true;user id=sa;initial catalog=zpweb;data source=myservername 
如果使用sqlserver数据库,将provider=sqloledb.1;改为:server=localhost;即可。