mybind.Position = mybind.Position + 1 是不是一定要用在强类型dataset上
我看见一列子是用 position来移动数据指针,但是dataset是强类型的,但是我的不是强类型,我编码代码如下 public partial class 博禄德电子销售计划通知单 : Form
{
DataSet ds = new DataSet();
string strcnna = gongyong.strcn3;
BindingManagerBase mybind; //抽象类,管理绑定到相同的数据源,的数据成员的所有
public 博禄德电子销售计划通知单()
{
InitializeComponent();
}
private void chazhao_Click(object sender, EventArgs e)
{
string strwhere = "";
if (!string.IsNullOrEmpty(订单号.Text))
strwhere += "csocode like '%" + 订单号.Text + "%' and ";
if (!string.IsNullOrEmpty(合同号.Text))
strwhere += "cdefine2 like '%" + 合同号.Text + "%' and ";
if (strwhere!="") {
string zbmc = "主表";
strwhere = strwhere.Substring(0, strwhere.Length - 5);
string stemp = "select csocode as 订单号,ddate as 订单日期,ccusname as 客户简称,cdefine2 as 合同号,"
+ "cmemo as 备注1,cdefine12 as 备注2,cverifier as 审核人 from so_somain where " + strwhere;
linkdatabase link = new linkdatabase(); //自定义类,生成ds
ds.Clear(); //先清除掉再重新获得
ds = link.selectdataset2(strcnna, stemp,zbmc);//获得ds
mybind = BindingContext[ds, "主表"]; //进行绑定
//以下要开始绑定动作
Binding binda = new Binding("text", ds.Tables["主表"], "订单号", true);
Binding bindb = new Binding("text", ds.Tables["主表"], "订单日期", true);
Binding bindc = new Binding("text", ds.Tables["主表"], "客户简称", true);
Binding bindd = new Binding("text", ds.Tables["主表"], "合同号", true);
Binding binde = new Binding("text", ds.Tables["主表"], "备注1", true);
Binding bindf = new Binding("text", ds.Tables["主表"], "备注2", true);
Binding bindg = new Binding("text", ds.Tables["主表"], "审核人", true);
//先清除掉之前所有绑定
gongyong.qinbinging(this);
//再进行绑定
订单号.DataBindings.Add(binda);
订单日期.DataBindings.Add(bindb);
客户简称.DataBindings.Add(bindc);
合同号.DataBindings.Add(bindd);
备注A.DataBindings.Add(binde);
备注2.DataBindings.Add(bindf);
审核人.DataBindings.Add(bindg);
}
}
private void moveright_Click(object sender, EventArgs e)
{
mybind.Position = mybind.Position + 1;
}代码没有报错,只是用moveright移动指针,文本框上的数据没有变.