结合枚举做了一个可以显示系统的全部颜色的dropdownlist 看看代码 HTML: <%@ Page Language="C#" UICulture="zh-CHS" Culture="zh-CN" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindText(); } } void BindText() { //绑定颜色 string[] colorArray = Enum.GetNames(typeof(System.Drawing.KnownColor)); foreach(string color in colorArray) { ListItem item = new ListItem(color); item.Attributes.Add("style", "color:" + color); txt_color.Items.Add(item); } //绑定字体 System.Drawing.Text.InstalledFontCollection font; font = new System.Drawing.Text.InstalledFontCollection(); foreach (System.Drawing.FontFamily family in font.Families) { txt_Font.Items.Add(family.Name); } //字体大小 string[] sizeArray = Enum.GetNames(typeof(System.Web.UI.WebControls.FontSize)); listsize.DataSource = sizeArray; listsize.SelectedIndex = -1; listsize.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { show.Text = txt.Text; show.ForeColor = System.Drawing.Color.FromName(txt_color.SelectedItem.Text); show.Font.Name = txt_Font.SelectedItem.Text; if (listsize.SelectedIndex>0) { show.Font.Size = FontUnit.Parse(listsize.SelectedItem.Text); } else { show.Font.Size = FontUnit.Point(Int32.Parse(size.Text)); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <div> 选择字体颜色:<asp:DropDownList ID="txt_color" runat="server"> </asp:DropDownList><br /> <br /> 选择系统字体:<asp:DropDownList ID="txt_Font" runat="server"> </asp:DropDownList><br /> <br /> 选择字体大小:<asp:TextBox ID="size" runat="server"></asp:TextBox> <asp:RadioButtonList ID="listsize" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"> </asp:RadioButtonList> <br /> <br /> 请输入文字: <asp:TextBox ID="txt" runat="server"></asp:TextBox><br /> <br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="确定" /><br /> <br /> <asp:Label ID="show" runat="server"></asp:Label></div> </form> </body> </html> REFERER: http://www.cnblogs.com/Clingingboy/archive/2006/03/25/358326.html