ASP.NET取得所有顏色值示例
更新時間:2014年03月13日 17:26:52 作者:
這篇文章主要介紹了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ù)連接屬性的對話框,此時你可以進行設(shè)置了。一般地,我們首先選擇“提供程序”的選項卡,進行設(shè)置之后,再設(shè)置“連接”選項卡的相關(guān)屬性,其他的我就不說了。設(shè)置好之后,最后按“確定”??赡軙邢鄳?yīng)的提示,你自己看著辦吧。
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;即可。
一句話搞定:comboBox1.Items.AddRange (FontFamily.Families);
(2)取得所有可用顏色并填充到asp.net的下拉菜單中:
復(fù)制代碼 代碼如下:
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ù)連接屬性的對話框,此時你可以進行設(shè)置了。一般地,我們首先選擇“提供程序”的選項卡,進行設(shè)置之后,再設(shè)置“連接”選項卡的相關(guān)屬性,其他的我就不說了。設(shè)置好之后,最后按“確定”??赡軙邢鄳?yīng)的提示,你自己看著辦吧。
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;即可。
相關(guān)文章
asp.net 使用js分頁實現(xiàn)異步加載數(shù)據(jù)
這篇文章主要介紹了asp.net使用js分頁實現(xiàn)異步加載數(shù)據(jù),需要的朋友可以參考下2014-04-04一文輕松了解ASP.NET與ASP.NET?Core多環(huán)境配置對比
ASP.NET?Core支持在多個環(huán)境中管理應(yīng)用程序,如開發(fā)(Development),預(yù)演(Staging)和生產(chǎn)(Production),下面這篇文章主要給大家介紹了關(guān)于ASP.NET與ASP.NET?Core多環(huán)境配置對比?的相關(guān)資料,需要的朋友可以參考下2022-04-04asp.net?core?configuration配置讀取的實現(xiàn)
本文主要介紹了asp.net?core?configuration配置讀取,configuration可以從命令行、環(huán)境變量、配置文件讀取配置,具有一定的參考價值,感興趣的可以了解一下2023-11-11.NET Framework攔截HTTP請求的實現(xiàn)
本文主要介紹了.NET Framework攔截HTTP請求的實現(xiàn),主要用于記錄 HTTP 信息,調(diào)試程序、分析程序性能等方面,具有一定的參考價值,感興趣的可以了解一下2024-03-03使用.NET?6開發(fā)TodoList應(yīng)用之引入數(shù)據(jù)存儲的思路詳解
在這篇文章中,我們僅討論如何實現(xiàn)數(shù)據(jù)存儲基礎(chǔ)設(shè)施的引入,具體的實體定義和操作后面專門來說。對.NET?6開發(fā)TodoList引入數(shù)據(jù)存儲相關(guān)知識感興趣的朋友一起看看吧2021-12-12asp.net實現(xiàn)在XmlTextWriter中寫入一個CDATA的方法
這篇文章主要介紹了asp.net實現(xiàn)在XmlTextWriter中寫入一個CDATA的方法,結(jié)合實例形式分析了XmlTextWriter寫入CDATA的步驟與相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2016-04-04