datagrid(winform)指向不同记录时,文本框的内容随之改变
请教:datagrid(winform)指向不同数据记录时,与数据集绑定的文本框的内容随之改变!!
------解决方案--------------------
ds = dbconn.selectTempDataSaveIn();
this.mybind = this.BindingContext[this.ds, "ds "];
//绑定控件
this.dataGridView1.DataSource = this.ds;
this.dataGridView1.DataMember = "ds ";
this.txtDate.DataBindings.Add( "Text ", this.ds, "ds.txtDate ");
this.txtAcc.DataBindings.Add( "Text ", this.ds, "ds.user_Acc ");
this.txtBH.DataBindings.Add( "Text ", this.ds, "ds.txtNum ");
private void bt_Prve_Click(object sender, EventArgs e)
{
if (this.mybind.Position > 0)
{
this.mybind.Position -= 1;
}
else
MessageBox.Show( "当前记录已经是第一条 ");
}
private void bt_Next_Click(object sender, EventArgs e)
{
if (this.mybind.Position < this.mybind.Count - 1)
{
this.mybind.Position += 1;
}
else
MessageBox.Show( "当前记录已经是最后一条 ");
}
private void bt_Frist_Click(object sender, EventArgs e)
{
this.mybind.Position = 0; //第一条记录
}
private void bt_Last_Click(object sender, EventArgs e)
{
this.mybind.Position = this.mybind.Count - 1; //最后一条记录
}