你可以使用CurrencyMangager类
private CurrencyManager myCurrencyManager;
private void BindControl(DataTable myTable){
// Bind a TextBox control to a DataTable column in a DataSet.
textBox1.DataBindings.Add("Text", myTable, "CompanyName");
// Specify the CurrencyManager for the DataTable.
myCurrencyManager = (CurrencyManager)this.BindingContext[myTable];
// Set the initial Position of the control.
myCurrencyManager.Position = 0;
}
private void MoveNext(CurrencyManager myCurrencyManager){
if (myCurrencyManager.Position == myCurrencyManager.Count - 1){
MessageBox.Show("You're at end of the records");
}
else{
myCurrencyManager.Position += 1;
}
}
private void MoveFirst(CurrencyManager myCurrencyManager){
myCurrencyManager.Position = 0;
}
private void MovePrevious(CurrencyManager myCurrencyManager ){
if(myCurrencyManager.Position == 0) {
MessageBox.Show("You're at the beginning of the records.");
}
else{
myCurrencyManager.Position -= 1;
}
}
private void MoveLast(CurrencyManager myCurrencyManager){
myCurrencyManager.Position = myCurrencyManager.Count - 1;
}
private CurrencyManager myCurrencyManager;
private void BindControl(DataTable myTable){
// Bind a TextBox control to a DataTable column in a DataSet.
textBox1.DataBindings.Add("Text", myTable, "CompanyName");
// Specify the CurrencyManager for the DataTable.
myCurrencyManager = (CurrencyManager)this.BindingContext[myTable];
// Set the initial Position of the control.
myCurrencyManager.Position = 0;
}
private void MoveNext(CurrencyManager myCurrencyManager){
if (myCurrencyManager.Position == myCurrencyManager.Count - 1){
MessageBox.Show("You're at end of the records");
}
else{
myCurrencyManager.Position += 1;
}
}
private void MoveFirst(CurrencyManager myCurrencyManager){
myCurrencyManager.Position = 0;
}
private void MovePrevious(CurrencyManager myCurrencyManager ){
if(myCurrencyManager.Position == 0) {
MessageBox.Show("You're at the beginning of the records.");
}
else{
myCurrencyManager.Position -= 1;
}
}
private void MoveLast(CurrencyManager myCurrencyManager){
myCurrencyManager.Position = myCurrencyManager.Count - 1;
}
解决方案 »
- 关于打包的问题
- silverlight 实现类似word的特殊字符输入工具
- datagridview获取输入焦点
- 改变数据源刷新窗体?
- 哪里能找到C#的类继承图呢?
- 各位大侠偶的头命小弟来此招人,要求c# 做 erp 要牛b 待遇面谈在广州工作 qq 85743282 msn [email protected]
- 获取赋值~~
- 用C#写的程序出现outofmemory错误,知道如何解决么?
- 求教: 如何得批量的文件名
- 如何将修改后的DataGrid所有数据导入Crystal Report预览和打印
- 我是C#新手,希望各位高手,能介绍基本你们看的参考书,最好是电子书!
- 关与WEBREQUEST和WEBRESPONSE两个类获取网页数据的问题!
Stevetan81(Steve) :CurrencyMangager需要和数据源帮定,但我不希望那样去做。