您现在的位置是:网站首页> 编程资料编程资料
ASP.NET取得所有颜色值示例_实用技巧_
2023-05-24
253人已围观
简介 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;即可。
一句话搞定: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;即可。
相关内容
- GridView选择性导出Excel解决方案_实用技巧_
- DropDownList绑定数据表实现两级联动示例_实用技巧_
- C# 判断两张图片是否一致的快速方法_实用技巧_
- asp.net错误页面处理示例分享_实用技巧_
- 上传图片后使用数据库保存图片的示例分享_实用技巧_
- C#默认以管理员身份运行程序实现代码_实用技巧_
- C#设置本地网络如DNS、网关、子网掩码、IP等等_实用技巧_
- 上传图片前判断文件格式与大小验证文件是不是图片_实用技巧_
- asp.net+ajax+sqlserver自动补全功能实现解析_实用技巧_
- ASP.NET小结之MVC, MVP, MVVM比较以及区别(一)_实用技巧_
