用C#,如何实现“前一条记录”“后一条记录”的操纵?

eyeoftiger 2002-04-17 03:49:48
如何实现movefirst和movelast???
...全文
73 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
acptvb 2002-04-18
  • 打赏
  • 举报
回复
感谢您使用微软产品。

在.net Framework中,每一个Windows Form均有一个BindingContext对象。同时,任何绑定到Windows Control上的数据源均有一个相关的CurrencyManager对象, CurrencyManager对象跟踪数据源的位置。Windows Form的BindingContext对象则可跟踪窗体上的所有CurrencyManager对象。因此,可采用如下代码来移动数据记录:
……
//用于绑定文本框txtCustomerID到字段authors.au_id
this.txtCustomerID.DataBindings.Add(new Binding("Text",this.myDataSet,"authors.au_id"));
"authors.au_id"))
//用于绑定文本框txtAddress到字段authors.address
this.txtAddress.DataBindings.Add(new Binding("Text",this.myDataSet,"authors.address"));

……
this.BindingContext[myDataSet, "authors"].Position -= 1 (使用窗体的BindingContext对象来递减数据集中的记录指针)
this.BindingContext[myDataSet, "authors"].Position += 1 (Move Next)
this.BindingContext[myDataSet, "authors"].Position = 0 (Move First)
this.BindingContext[myDataSet, "authors"].Position = this.BindingContext[myDataSet, "authors"].Count-1 (Move Last)
希望以上这些信息对您有帮助。

关于BindingContext的更详细信息及示例(中文信息),请参考微软官方网站:
http://www.microsoft.com/china/msdn/library/dndotnet/html/databindingadonet.asp

— 微软全球技术中心 VB支持中心

本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
  • 打赏
  • 举报
回复
在一个表中(Table)也可以使用select,它返回一个row的集合,你可以对此集合进行处理。
bianbiancheng 2002-04-17
  • 打赏
  • 举报
回复
this.BindingContext[myDataSet,strTable].position=this.BindingContext[myDataSet,strTable].position+1
this.BindingContext[myDataSet,strTable].position=this.BindingContext[myDataSet,strTable].position-1
说明:myDataSet是一个数据集。(DataSet)
strTable 是表名 ,是string型。
chechy 2002-04-17
  • 打赏
  • 举报
回复
不用movefirst,movelast了。.net的Record都存在DataTable的Rows属性中。
foreach (DataRow row in dataTable.Rows)
{
// do each things for row
}

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧