資源簡介
本方法和用checkbox, listbox等控件和事件拼湊出來的不同,本方法是一個集成的獨立控件,基本實現了控件的順滑度,下拉框可懸浮等效果,可以認為是comboBox的升級版,使用方便,僅需引用編譯好的DLL,直接在toolBox拖拽出控件即可。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Drawing;
using?System.Data;
using?System.Text;
using?System.Windows.Forms;
using?System.Reflection;
using?System.Collections.objectModel;
using?System.Collections.Specialized;
namespace?PresentationControls
{
????///?
????///?Martin?Lottering?:?2007-10-27
????///?--------------------------------
????///?This?is?a?usefull?control?in?Filters.?Allows?you?to?save?space?and?can?replace?a?Grouped?Box?of?CheckBoxes.
????///?Currently?used?on?the?TasksFilter?for?TaskStatusses?which?means?the?user?can?select?which?Statusses?to?include
????///?in?the?“Search“.
????///?This?control?does?not?implement?a?CheckBoxListBox?instead?it?adds?a?wrapper?for?the?normal?ComboBox?and?Items.?
????///?See?the?CheckBoxItems?property.
????///?----------------
????///?ALSO?IMPORTANT:?In?Data?Binding?when?setting?the?DataSource.?The?ValueMember?must?be?a?bool?type?property?because?it?will?
????///?be?binded?to?the?Checked?property?of?the?displayed?CheckBox.?Also?see?the?DisplayMemberSingleItem?for?more?information.
????///?----------------
????///?Extends?the?CodeProject?PopupComboBox?“Simple?pop-up?control“?“http://www.codeproject.com/cs/miscctrl/simplepopup.asp“
????///?by?Lukasz?Swiatkowski.
????///?
????public?partial?class?CheckBoxComboBox?:?PopupComboBox
????{
????????#region?CONSTRUCTOR
????????public?CheckBoxComboBox()
????????????:?base()
????????{
????????????InitializeComponent();
????????????_CheckBoxProperties?=?new?CheckBoxProperties();
????????????_CheckBoxProperties.PropertyChanged?+=?new?EventHandler(_CheckBoxProperties_PropertyChanged);
????????????//?Dumps?the?ListControl?in?a(nother)?Container?to?ensure?the?ScrollBar?on?the?ListControl?does?not
????????????//?Paint?over?the?Size?grip.?Setting?the?Padding?or?Margin?on?the?Popup?or?host?control?does
????????????//?not?work?as?I?expected.?I?don‘t?think?it?can?work?that?way.
????????????CheckBoxComboBoxListControlContainer?ContainerControl?=?new?CheckBoxComboBoxListControlContainer();
????????????_CheckBoxComboBoxListControl?=?new?CheckBoxComboBoxListControl(this);
????????????_CheckBoxComboBoxListControl.Items.CheckBoxCheckedChanged?+=?new?EventHandler(Items_CheckBoxCheckedChanged);
????????????ContainerControl.Controls.Add(_CheckBoxComboBoxListControl);
????????????//?This?padding?spaces?neatly?on?the?left-hand?side?and?allows?space?for?the?size?grip?at?the?bottom.
????????????ContainerControl.Padding?=?new?Padding(4?0?0?14);
????????????//?The?ListControl?FILLS?the?ListContainer.
????????????_CheckBoxComboBoxListControl.Dock?=?Dockstyle.Fill;
????????????//?The?DropDownControl?used?by?the?base?class.?Will?be?wrapped?in?a?popup?by?the?base?class.
????????????DropDownControl?=?ContainerControl;
????????????//?Must?be?set?after?the?DropDownControl?is?set?since?the?popup?is?recreated.
????????????//?NOTE:?I?made?the?dropDown?protected?so?that?i
- 上一篇:SVM源代碼和測試圖片
- 下一篇:磁鏈觀測方案.pdf
評論
共有 條評論