c# - 重新创建 "Font"属性行为

标签 c# asp.net intellisense web-controls system.componentmodel

继承 System.Web.UI.WebControls.WebControl 的控件有一个名为 Font 的属性。类型是 System.Web.Ui.WebControls.FontInfo

在设计器中使用这些控件时,它会将 Font 属性分解为多个属性,例如 Font-BoldFont-Italic等。在代码隐藏中使用这些相同的 WebControl 时,只有一个 Font 属性(没有 Font-BoldFont-Italic 等).

如何在创建 WebControl 时手动重新创建此行为?具体来说,System.ComponentModel 属性的哪些组合可以在 Intellisense 中显示/隐藏这些属性?

最佳答案

您应该能够访问粗体、斜体等作为 bool 属性:

http://msdn.microsoft.com/it-it/library/system.web.ui.webcontrols.fontinfo.aspx

  void Page_Load(object sender, EventArgs e)
  {
    // When the page loads, set the the myLabel Label control's FontInfo properties.
    // Note that myLabel.Font is a FontInfo object.

    myLabel.Font.Bold = true;
    myLabel.Font.Italic = false;
    myLabel.Font.Name = "verdana";
    myLabel.Font.Overline = false;
    myLabel.Font.Size = 10;
    myLabel.Font.Strikeout = false;
    myLabel.Font.Underline = true;

    // Write information on the FontInfo object to the myLabel label.
    myLabel.Text = myLabel.Font.ToString();

  }

关于c# - 重新创建 "Font"属性行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3118142/

相关文章:

TypeScript 仅作为声明导入?

javascript - 文本区域上的智能感知插件?

c# - 在工具提示 WPF 上使用 Storyboard

c# - ASP ImageButton 与按钮

.net - 复选框 Gridview 启用和禁用

c# - 如何在 ASP.NET MVC View 中获取对象属性的子字符串?

c# - 将 AxShockwaveFlash Flash 对象写入文件 C#

c# - 使用纬度/经度计算最近点的距离?

asp.net - 如何自定义 Asp.net Identity 2 用户名已获取验证消息?

visual-studio-2010 - Vs2010 使用 log4net 和 Intellisense