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