this.BindingContext[dv].Position = this.BindingContext[dv].Position - 1;
解决方案 »
- DevExpress 的Gridcontrol 控件怎么设置默认排序字段及排序方式。我在数据库查询中已经设置了排序字段。但是Gridcontrol 显示时会把
- 读取tsv文件的问题,在线急求
- VC#.net中如何自定义文件存储格式
- c#读取excel单元格的合并情况???我找遍了论坛,好像想没人遇到这问题啊?
- 100分请高手赐教,关于winform的登录
- asp.net中数据以Excel输出时遇到的怪异问题?欢迎有兴趣的朋友进来讨论一下?
- 如何让一个按钮可以得到点击事件,但却永远不能获得焦点?
- 谁有C# 驱动级截图的资料
- 一个新手的小问题
- 有关DevExpress中chartTable的问题?
- 怎么才能把datagrid的一列删除掉
- 《C# Web服务高级编程》和《ASP.NET WEB服务高级编程》有没有必要都买?
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;namespace WindowsApplication5
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public DataSet ds;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(56, 64);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(232, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(192, 96);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.textBox1});
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
string source="data source=mydata;initial catalog=tjqqbdc;integrated security=SSPI;";
string select="select danci from shengcibiao ;";
SqlConnection conn=new SqlConnection(source); SqlDataAdapter ad=new SqlDataAdapter(select ,source);
ds=new DataSet();
ad.Fill(ds,"shengcibiao");
this.textBox1.DataBindings.Add("Text",ds.Tables[0],"danci"); } private void button1_Click(object sender, System.EventArgs e)
{
this.BindingContext[ds].Position+=1;
}
}
}
DataView dv = ds.Tables[0].DefauldView;
(
this.textBox1.DataBindings.Add("Text",ds.Tables[0],"danci");
改为
this.textBox1.DataBindings.Add("Text",dv,"danci");
)
(
this.BindingContext[ds].Position+=1;
改为
this.BindingContext[dv].Position+=1;
)
您再试试!!
t_booktitle.DataBindings.Add ( "Text" , myDataSet , "books.booktitle" ) ;
t_bookauthor.DataBindings.Add ( "Text" , myDataSet , "books.bookauthor" ) ;
t_bookprice.DataBindings.Add ( "Text" , myDataSet , "books.bookprice" ) ;
t_bookstock.DataBindings.Add ( "Text" , myDataSet , "books.bookstock" ) ;
//设定 BindingManagerBase
//把对象DataSet和"books"数据表绑定到此myBind对象
myBind = this.BindingContext [ myDataSet , "books" ] ;
//"下一条"按钮对应的事件
protected void GoNext ( object sender , System.EventArgs e )
{
if ( myBind.Position == myBind.Count - 1 )
MessageBox.Show ( "已经到尾记录!" ) ;
else
myBind.Position += 1 ;
}