資源簡介
在我們的客戶端應(yīng)用程序開發(fā)中,可能會(huì)涉及大量的控件操作的代碼,如 TreeView,DataGridView,ListBox 等等,這些控件雖然都提供了基本的數(shù)據(jù)操作接口,但是這些接口的功能都非常的基礎(chǔ)和簡單,考慮如下操作:
在控件中使指定的數(shù)據(jù)處于選中狀態(tài);
在控件中刪除符合條件的數(shù)據(jù);
向控件中的指定位置添加數(shù)據(jù),并判斷數(shù)據(jù)的類型是否符合預(yù)期;
在控件中查找符合條件的數(shù)據(jù);
獲取控件中選中的數(shù)據(jù),直接返回強(qiáng)類型結(jié)果;
移動(dòng)指定的數(shù)據(jù)到另一個(gè)數(shù)據(jù)項(xiàng)目之前/之后;
展開樹控件中符合條件的樹節(jié)點(diǎn);
這些操作有一個(gè)重要的共同點(diǎn),都是針對“數(shù)據(jù)”進(jìn)行操作,但是基本的的控件接口,沒有這么多功能,既有的接口也多是以 object 作為參數(shù)來操作的,如果要實(shí)現(xiàn)這些功能,很多時(shí)候程序員需要寫一些“業(yè)務(wù)代碼”來完成,在業(yè)務(wù)代碼中迭代數(shù)據(jù)源,寫條件判斷,做類型轉(zhuǎn)換,最后調(diào)用控件的基本操作接口。
Sheng.Winform.Controls.Controller 使用控制器,來為這些控制提供這些共通的操作,包括:
DataGridViewController
TabControlController
TreeViewController
ListBoxController
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Diagnostics;
using?System.Windows.Forms;
using?System.ComponentModel;
using?System.Collections;
namespace?Sheng.Winform.Controls.Controller
{
????/*
?????*?MSDN?ListBox:
?????*?除了顯示和選擇功能外,ListBox?還提供一些功能,使您得以有效地將項(xiàng)添加到?ListBox?中以及在列表的項(xiàng)內(nèi)查找文本。
?????*?BeginUpdate?和?EndUpdate?方法使您得以將大量項(xiàng)添加到?ListBox?中,而不必每次將一個(gè)項(xiàng)添加到列表中時(shí)都重新繪制該控件
?????*?。FindString?和?FindStringExact?方法使您得以在列表中搜索包含特定搜索字符串的項(xiàng)。
?????*/
????public?class?ListBoxController
????{
????????#region?私有成員
????????private?ListBox?_listBox;
????????///?
????????///?當(dāng)前所綁定的對象的對象類型
????????///?
????????private?Type?_currentType;
????????private?BindingListject>?_bindingList?=?new?BindingListject>();
????????#endregion
?????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\
?????目錄???????????0??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\DataGridViewController\
?????文件????????2947??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\DataGridViewController\ITypeBinderDataGridViewTypeCodon.cs
?????文件????????9190??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\DataGridViewController\TypeBinderDataGridViewComboTypeCodon.cs
?????文件???????36807??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\DataGridViewController\TypeBinderDataGridViewController.cs
?????文件????????6508??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\DataGridViewController\TypeBinderDataGridViewTypeCodon.cs
?????文件????????1079??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\LICENSE
?????文件???????14377??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\ListBoxController.cs
?????文件????????1444??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\README.md
?????目錄???????????0??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TabControlController\
?????文件????????4411??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TabControlController\TabControlController.cs
?????文件????????1023??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TabControlController\TypeBinderTabPage.cs
?????目錄???????????0??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TreeViewController\
?????文件????????2279??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TreeViewController\ITypeBinderTreeViewNode.cs
?????文件???????23766??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TreeViewController\TypeBinderTreeViewController.cs
?????文件????????5285??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TreeViewController\TypeBinderTreeViewNode.cs
?????文件????????7347??2018-06-08?14:58??Sheng.Winform.Controls.Controller-master\TreeViewController\TypeBinderTreeViewNodeCodon.cs
評論
共有 條評論