zoukankan      html  css  js  c++  java
  • ControlStyles(枚举)

    指定控件的样式和行为。

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

    ContainerControl:如果为true,则控件是类似容器的控件。

    UserPaint:如果为true,控件将自行绘制,而不是通过操作系统来绘制。如果为false,将不会引发 System.Windows.Forms.Control.Paint事件。此样式仅适用于派生自 System.Windows.Forms.Control的类。

    Opaque:如果为true,则控件被绘制为不透明的,不绘制背景。

    ResizeRedraw:如果为true,则在调整控件大小时重绘控件。

    FixedWidth:如果为true,则自动缩放时,控件具有固定宽度。例如,如果布局操作尝试重新缩放控件以适应新的System.Drawing.Font,则控件的System.Windows.Forms.Control.Width 将保持不变。

    FixedHeight: 如果为 true,则自动缩放时,控件具有固定高度。 例如,如果布局操作尝试重新缩放控件以适应新的 System.Drawing.Font,则控件的  System.Windows.Forms.Control.Height 将保持不变。

    StandardClick:如果为true,则控件将实现标准 System.Windows.Forms .Control.Click 行为。

    Selectable:如果为true,则控件可以接受焦点.

    UserMouse:如果为true,则控件完成自己的鼠标处理,因而鼠标事件不由操作系统处理。

    SupportsTransparentBackColor:如果为true,控件接受alpha 组件小于255的System.Windows.Forms.Control.BackColor 以模拟透明。仅在System.Windows.Forms.ControlStyles.UserPaint位置为true 并且父控件派生自 System.Windows.Forms.Control 时才模拟透明。

    StandardDoubleClick:如果为true,则控件将实现标准 System.Windows.Forms.Control.DoubleClick行为。如果 System.Windows.Forms.ControlStyles.StandardClick 位未设置为true,则忽略此样式。

    AllPaintingInWmPaint:如果为true,控件将忽略 WM_ERASEBKGND 窗口消息以减少闪烁。仅当System.Windows.Forms.ControlStyles.UserPaint 位 设置为true时,才应当应用该样式。

    CacheText:如果为true,控件保留文本的副本,而不是在每次需要时从 System.Windows.Forms.Control.Handle 获取文本副本。次样式默认为false。此行为提高了性能,但使保持文本同步变得困难。

    EnableNotifyMessage: 如果为 true,则为发送到控件的 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message@)的每条消息调用 System.Windows.Forms.Control.OnNotifyMessage(System.Windows.Forms.Message)方法。 此样式默认为 false。 System.Windows.Forms.ControlStyles.EnableNotifyMessage在部分可信的情况下不工作。

    DoubleBuffer:如果为 true,则绘制在缓冲区中进行,完成后将结果输出到屏幕上。 双重缓冲区可防止由控件重绘引起的闪烁。 如果将 System.Windows.Forms.ControlStyles.DoubleBuffer设置为 true,则还应当将 System.Windows.Forms.ControlStyles.UserPaint 和 System.Windows.Forms.ControlStyles.AllPaintingInWmPaint 设置为 true。

    OptimizedDoubleBuffer:如果为 true,则该控件首先在缓冲区中绘制,而不是直接绘制到屏幕上,这样可以减少闪烁。 如果将此属性设置为 true,则还应当将 System.Windows.Forms.ControlStyles.AllPaintingInWmPaint设置为 true。

    UseTextForAccessibility:指定该控件的 Text 属性的值,如果已设置,则可确定该控件的默认 Active Accessibility 名称和快捷键。

    控件在各种属性和方法中使用此枚举指定功能。 控件可以通过调用 SetStyle 方法并传入适当的 ControlStyles 位以及设置该位的 Boolean 值来启用样式。 例如,下面的一行 Visual Basic 代码将会启用双重缓冲。 

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

    如果将 AllPaintingInWmPaint 位设置为 true,则将忽略 WM_ERASEBKGND 窗口消息,而直接从 WM_PAINT 窗口消息调用 OnPaintBackground 和 OnPaint 方法。 这通常可减少闪烁,除非其他控件将 WM_ERASEBKGND 窗口消息发送到该控件。 可以发送 WM_ERASEBKGRND 窗口消息以达到与SupportsTransparentBackColor 相似的假透明效果;例如,具有平面外观的 ToolBar 就采用这种方法。

    若要完全启用双缓冲,可以将 OptimizedDoubleBuffer 和 AllPaintingInWmPaint 位设置为 true。 但是,启用双缓冲的首选方法是将该控件的 DoubleBuffered 属性设置为 true,这会产生同样的结果。

    如果 SupportsTransparentBackColor 位设置为 true,并且 BackColor 被设置为 alpha 组件小于 255 的颜色,则 OnPaintBackground 将通过请求其父控件绘制背景来模拟透明。 但这不是真正的透明。

    说明 说明

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

    当 UserMouse 位设置为 true 时,仍将调用以下方法:Control.OnMouseDownControl.OnMouseUpControl.OnMouseEnterControl.OnMouseMoveControl.OnMouseHoverControl.OnMouseLeave 和Control.OnMouseWheel

    单击控件时,如果 StandardClick 位设置为 true,则 Control.OnClick 方法被调用,它将引发 Control.Click 事件。 双击控件并且 StandardClick 和StandardDoubleClick 位都设置为 true 时,会将此次单击传递给 DoubleClick 事件。 随后,Control.OnDoubleClick 方法被调用,此方法将引发Control.DoubleClick 事件。 然而,无论 StandardClick 和 StandardDoubleClick 位为何值,控件都可直接调用 OnClick 或 OnDoubleClick 有关控件单击和双击行为的更多信息,请参见 Control.Click 和 Control.DoubleClick 这两个主题。

    当已设置 UseTextForAccessibility 位和该控件的Text属性值时,该控件的Text属性值可确定控件的默认的 Active Accessibility 名称和快捷键。 否则,将改用前面的 Label 控件的文本。 此样式为默认设置。 某些内置控件类型(如 TextBox和 ComboBox)会重置此样式,因此 Active Accessibility 不会使用那些控件的Text属性。

    对继承者的说明

    如果该控件不支持 Click 或 DoubleClick 事件,那么从标准 Windows 窗体控件继承并将 StandardClick 或 StandardDoubleClick 位值更改为 true 会导致意外的行为,或者根本不会产生任何效果。


     

    下面的示例演示如何通过 StyleChanged 事件使用 ControlStyles。

  • 相关阅读:
    如何描述一个前端开发程序员
    解决电脑性能一般,打开webstorm后,电脑比较卡的问题
    HTML5的5个的新特性
    js 数组的拼接
    移动端性能
    如何学习前端
    实战:上亿数据如何秒查
    读懂Java中的Socket编程
    远程管理软件
    dedecms 安装后 管理后台ie假死 无响应的解决方法
  • 原文地址:https://www.cnblogs.com/tianma3798/p/3961104.html
Copyright © 2011-2022 走看看