gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 11:47:12 24 4
gpt4 key购买 nike

继承 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com