首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > 服务器相关 > Using the CurrencyManager
【标  题】:Using the CurrencyManager
【关键字】:Using,the,CurrencyManager
【来  源】:http://www.cnitblog.com/wuming3000/archive/2006/10/26/18471.html

Using the CurrencyManager

昨天写一个代码感觉CurrencyManager运用在DataGrvdView中用处很大 所以摘录一些内容来学习参考


You use the CurrencyManager object if you want to keep data-bound controls synchronized with each other which means showing data from the same record. For example: if you want to add a TextBox control to a form and bind it to a column of a table (e.g., Customers.FirstName) in a DataSet (e.g., dSet), the control is going to communicate with the BindingContext object for this form. In turn, the BindingContext object is going to talk to the specific CurrencyManager object for the data the TextBox control is binding.

Every Windows Form has a BindingContext object keeping track of all the CurrencyManager objects on the Windows Form. CurrencyManager keeps track of the position in the data source. When you bind a data object to a control (i.e., TextBox), a CurrencyManager object is automatically assigned. If you bind several controls to the same data source, they share the same CurrencyManager.

In a normal case where you are using an ADO.NET database (connecting and closing database) and displaying the records, e.g., in a DataGrid, you never need the CurrencyManager object. But if you want to know the exact position within a data structure (e.g., table in your database) as I did, you have to use the CurrencyManager object because the CurrencyManager has the Position property for this purpose. You can, for example, manipulate the Position property in a Next or Previous or First or Last button which I did in my program as well.
For example:
If you want to know how many records are in a DataTable, you simply query the BindingContext object's Count property
this.BindingContext[dataset1,"PersonTable"].Count - 1 ;
If you want to get the current position from the BindingContext object:
this.BindingContext[dataset1, "PersonTable"].Position + 1;

After data binding, you call and initialize CurrencyManager for your table. Here is the method I used to initialize the CurrencyManager for the table "PersonTable":
public void fnSetCurrencyManager()
{
? currManager = (CurrencyManager)this.
? BindingContext [ datc.dSet.Tables["PersonTable"]] ;
}

农林大学软件基地的学生终于暴动了:【上一篇】
C#用户窗体登陆设计:【下一篇】
【相关文章】
  • EtherAP (802.1X Authenticator)- 基于802.1X的网络端口访问控制解
  • [译]外观设计模式(The Facade Pattern) From Chapter 6 of《Design Patterns Explained》
  • Preparing the demo of the Sloth.
  • The design diagrams
  • HACMP Error:inconsistent with the time stamp in th
  • Hacmp Error:Cluster IPC error: The IPC connection
  • Getting the Current Cell Id using Symbian S60
  • Chapter 2. Creating and Using Stylesheets中关于模版的引用
  • 从Atlas到Microsoft ASP.NET AJAX(9) - Using the Value-add Scripts
  • what is the clustering_factor ?
  • 【随机文章】
  • 打造不完美的超级帐号
  • 配置辅助端口
  • barracuda SPAM firewall 安装注意事项!
  • 一个简单的抓包程序(zz)
  • XML Schema指南(二)之Complex Types
  • Could not find the main class. Program will exit
  • ThinkingInJava3(中文版)__第十一章:对像的集合
  • grep 过滤配置文件中的注释语句
  • ORA-27069: skgfdisp: 尝试在文件范围外执行 I/O
  • ssh相关
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.