C# FontStyle枚举的使用
FontStyle同时是bold,Underline,Strikeout风格:
FontStyle style = FontStyle.Regular;
style |= FontStyle.Bold;
style |= FontStyle.Italic;
//將String转换成FontStyle枚举
FontStyle fsStyle = (FontStyle)Enum.Parse(typeof(FontStyle), sContentFontStyle);
sContentFontStyle為FontStyle的string值,多個時以","分隔 。如:
FontStyle fsStyle = (FontStyle)Enum.Parse(typeof(FontStyle), "Bold,Italic,Underline,Strikeout");
FontStyle style = FontStyle.Regular;
style |= FontStyle.Bold;
style |= FontStyle.Italic;
如果是去掉某一种的话是:
style-=FontStyle.Bold;
//將String转换成FontStyle枚举
FontStyle fsStyle = (FontStyle)Enum.Parse(typeof(FontStyle), sContentFontStyle);
sContentFontStyle為FontStyle的string值,多個時以","分隔 。如:
FontStyle fsStyle = (FontStyle)Enum.Parse(typeof(FontStyle), "Bold,Italic,Underline,Strikeout");
本文详细介绍了C#中FontStyle枚举的使用方法,包括如何设置字体样式为粗体、斜体、下划线及删除线等复合样式,以及如何通过字符串转换为FontStyle枚举值。
324

被折叠的 条评论
为什么被折叠?



