zoukankan      html  css  js  c++  java
  • 下拉框控件 转http://www.bradsmith.info/blog/archives/477 武胜

    Drop-Down Controls Revisited

    From time to time, it’s a good idea to go back and re-examine old code. With time comes greater knowledge and new tricks; and in the case of two of my earlier custom Windows Forms controls, this was certainly true. You may remember my ComboBox control with grouping support, as well as my ComboBox with a TreeView drop-down – I have revisited these controls, with particular mind to implementing what I learnt from my experience with the Buffered Paint API.

    New versions of GroupedComboBox and ComboTreeBoxGroupedComboBox

    To refresh your memory, this control extends ComboBox and adds a new property; GroupMember. Using PropertyDescriptor and owner-drawing, it groups together items whose grouping values are equal.

    What’s new:

    • On Windows Vista and 7, the control did not appear in the ‘button style’ consistent with normal ComboBox controls in DropDownList mode; this is a limitation of owner-drawing, but one that can be overcome through the use of VisualStyleRenderer. This is a slightly dodgy hack in that it pre-supposes the appearance of the ComboBox in this mode, but the functionality is only applied when the OS is identified as Vista or 7.
    • The control is inconsistent with other ComboBox controls because it is not animated. With the BufferedPainter<T> class I developed, implementing buffered animation was simple.

    ComboTreeBox

    The ComboTreeBox is a control developed entirely from scratch (i.e. its base class is Control) that uses a hierarchical/tree structure as its data representation (instead of a flat list). As such, it has behaviours in common with both ComboBox and TreeView. The drop-down/pop-up portion of the control is implemented using ToolStripDropDown, bitmap caching and custom rendering.

    What’s new:

    • As with GroupedComboBox, the control did not appear in the Windows Vista/7 style. As the control has no editable portion and is entirely owner-drawn, it was easy to simulate the appearance under the appropriate OS. Under XP, it falls back to the default visual style. When themes are disabled, it draws in the classic style.
    • The control was not animated. Once again, BufferedPainter<T> was used to implement animation.
    • Due to a strongly-typed reference to its designer class, the control previously did not work with the “Client Profile” version of the .NET Framework. Rather cheekily, I have substituted my custom designer for the built-in designer that the DomainUpDown control uses – this works well for constraining the height of the control and avoids the need to reference the System.Design assembly (included only with the full version of the framework).
    • Minor tweaks were made to the way focused items are drawn; this is only apparent if focus cues are enabled in Windows.

    Download

    DropDownControlsUpdated.zip (Visual Studio 2010 Solution, .NET Framework 4 Client Profile)

  • 相关阅读:
    分布式服务框架 Zookeeper — 管理分布式环境中的数据
    分布式消息队列(二)
    分布式消息队列(一)
    数据库事务的四大特性以及事务的隔离级别
    php--yii2.0的安装
    php--字符串函数分类总结
    一张表有三个字段:id(城市id) Cityname(城市名) Privence(所属省份)如果要统计每个省份有多少城市请用SQL实现。
    TP自带的缓存机制
    php——n维数组的遍历——递归
    php--分享插件
  • 原文地址:https://www.cnblogs.com/zeroone/p/2722328.html
Copyright © 2011-2022 走看看