ASP.NET取得所有顏色值示例

字號:


    這篇文章主要介紹了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)怎樣取得數(shù)據(jù)庫的連接字符串?
    A. 新建一個文本文件,文件名使用*.udl(比如:myDB.udl),此時發(fā)現(xiàn)圖標變成數(shù)據(jù)庫連接的圖標了。
    B. 雙擊此文件,彈出數(shù)據(jù)連接屬性的對話框,此時你可以進行設置了。一般地,我們首先選擇“提供程序”的選項卡,進行設置之后,再設置“連接”選項卡的相關屬性,其他的我就不說了。設置好之后,最后按“確定”。可能會有相應的提示,你自己看著辦吧。
    C. 用記事本打開你剛才的這個文件。里面有類似這樣的字符串:
    Provider=SQLOLEDB.1;Password=123456sa;Persist Security Info=True;User ID=sa;Initial Catalog=ZPWeb;Data Source=MyServerName
    如果使用SQLSERVER數(shù)據(jù)庫,將Provider=SQLOLEDB.1;改為:Server=localhost;即可。