ControlStyles 枚举
.NET Framework 4
 

指定控件的样式和行为。

此枚举有一个 FlagsAttribute 特性,通过该特性可使其成员值按位组合。

 

命名空间:  System.Windows.Forms
程序集:  System.Windows.Forms(在 System.Windows.Forms.dll 中)
C# 
[FlagsAttribute]
public enum ControlStyles
成员名称 说明
ContainerControl true,则控件是类似容器的控件。
UserPaint Control 的类。
Opaque true,则控件被绘制为不透明的,不绘制背景。
ResizeRedraw true,则在调整控件大小时重绘控件。
FixedWidth Width 将保持不变。
FixedHeight Height 将保持不变。
StandardClick Click 行为。
Selectable true,则控件可以接收焦点。
UserMouse true,则控件完成自己的鼠标处理,因而鼠标事件不由操作系统处理。
SupportsTransparentBackColor Control 时才模拟透明。
StandardDoubleClick true,则忽略此样式。
AllPaintingInWmPaint true 时,才应当应用该样式。
CacheText 此行为提高了性能,但使保持文本同步变得困难。
EnableNotifyMessage EnableNotifyMessage 在部分可信的情况下不工作。
DoubleBuffer true。
OptimizedDoubleBuffer true。
UseTextForAccessibility Text 属性的值,如果已设置,则可确定该控件的默认 Active Accessibility 名称和快捷键。

例如,下面的一行 Visual Basic 代码将会启用双重缓冲。

 myControl.SetStyle(UserPaint Or AllPaintingInWmPaint Or DoubleBuffer, True)

ToolBar 就采用这种方法。

true,这会产生同样的结果。

但这不是真正的透明。

注意

如果在控件与其父控件之间还有另一个控件,则当前控件不会显示中间的控件。

Control.OnMouseWheel。

Control.DoubleClick 这两个主题。

Text 属性。

对继承者的说明

true 会导致意外的行为,或者根本不会产生任何效果。

ControlStyles。

// Set the 'FixedHeight' and 'FixedWidth' styles to false.
private void MyForm_Load(object sender, EventArgs e)
{
   this.SetStyle(ControlStyles.FixedHeight, false);
   this.SetStyle(ControlStyles.FixedWidth, false);
}

private void RegisterEventHandler()
{
   this.StyleChanged += new EventHandler(MyForm_StyleChanged);
}

// Handle the 'StyleChanged' event for the 'Form'.
private void MyForm_StyleChanged(object sender, EventArgs e)
{
   MessageBox.Show("The style releated to the 'Form' has been changed");
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
  • 2021-06-11
  • 2022-12-23
  • 2021-11-28
  • 2021-07-25
猜你喜欢
  • 2021-08-17
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案