这里也没有什么好说的,就是利用了System.Drawing.Test.installedFontCollection这个类,下来可以对这个类作进一步的研究
2.添加字号代码
| // <summary> /// 得到字体的大小 /// </summary> public void getSize() { for (int i = 1; i < 70;i++ ) DropDownList2.Items.Add(i.ToString()); |
3.颜色代码
| /// <summary> /// 得到字体颜色 /// </summary> public void getColor() { DropDownList3.Items.Add("Color.AliceBlue"); DropDownList3.Items.Add("Color.Blue"); DropDownList3.Items.Add("Color.Yellow"); } |
| protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { TextBox4.Font.Name = DropDownList1.SelectedItem.Value; } protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e) { TextBox4.ForeColor = Color.Brown; } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { TextBox4.Font.Size = FontUnit.Parse(DropDownList2.SelectedItem.Value); } protected void chkBold_CheckedChanged(object sender, EventArgs e) { TextBox4.Font.Bold = chkBold.Checked ? true : false; } protected void chkUnderline_CheckedChanged(object sender, EventArgs e) { TextBox4.Font.Underline = chkUnderline.Checked?true: false; } protected void chkStrikOut_CheckedChanged(object sender, EventArgs e) { TextBox4.Font.Strikeout = chkStrikOut.Checked ? true : false; } |

