比如已知订单号,订单分号,在dbgrid中定位到相应的订单分号?我现在要子表里定位是用循环,实要是笨极了(学了两个月c#,看来还没有入门啊555): int danH = inq.DanHao;
int bianH = inq.BianHao; object[] criteria1 = new object[] {danH};
this.dsGoals1.DanInfo.DefaultView.Sort="DanHao";
int idx1 = this.dsGoals1.DanInfo.DefaultView.Find(criteria1);
this.BindingContext[this.dsGoals1,"DanInfo"].Position=idx1; int cnt = this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Count;
while (this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Position<cnt)
{
int bH = (GetRow(this.dGdAM.DataMember) as dsGoals.AMRow).BianHao;
if (bH == bianH)
break;
else
this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Position++;
}
this.LoadAMData();
int bianH = inq.BianHao; object[] criteria1 = new object[] {danH};
this.dsGoals1.DanInfo.DefaultView.Sort="DanHao";
int idx1 = this.dsGoals1.DanInfo.DefaultView.Find(criteria1);
this.BindingContext[this.dsGoals1,"DanInfo"].Position=idx1; int cnt = this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Count;
while (this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Position<cnt)
{
int bH = (GetRow(this.dGdAM.DataMember) as dsGoals.AMRow).BianHao;
if (bH == bianH)
break;
else
this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Position++;
}
this.LoadAMData();
解决方案 »
- asp.net C#,改变同一网站下的另一网页的背景图片
- c# winform中listView怎么异步加载网络图片?
- 菜鸟寻求帮助~~用C#做遥感影像的更新
- C#调试子进程
- 求类似网络硬盘客户端一样的源码!
- 做一个信息管理系统,有几个疑问,忘各位兄弟赐教!
- 比较两个bin文件,统计2相比1缺失的个数和错误的数据
- 大家帮帮忙,为什么我用 Dns.GetHostByAddress 只能访问内网?
- 一个小问题.VB.NET中 "dim fb" 用C#定义怎么写?
- 请问如何获取DataGrid中某行某列的数据值?
- 在C#使用COM 后如何获得系统异常后的HResult值?
- 如何获取调用本方法的方法名称?
int danH = inq.DanHao;
int bianH = inq.BianHao;
//父表直接查找
object[] criteria1 = new object[] {danH};
this.dsGoals1.DanInfo.DefaultView.Sort="DanHao";
int idx1 = this.dsGoals1.DanInfo.DefaultView.Find(criteria1);
this.BindingContext[this.dsGoals1,"DanInfo"].Position=idx1;//用循环在子表中定位,很笨,也很慢。请大吓们请教下面的代码该怎么改啊
int cnt = this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Count;
while (this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Position<cnt)
{
int bH = (GetRow(this.dGdAM.DataMember) as dsGoals.AMRow).BianHao;
if (bH == bianH)
break;
else
this.BindingContext[this.dsGoals1,"DanInfo.DanInfoAM"].Position++;
}this.LoadAMData();
DataTable table = ds.Tables[0];
DataRowCollection rows = table.Rows;
for(int row = 0; row < rows.Count; row++)
{
//查找
if(rows[row]["字段名"].toString.Equals("要比较的值"))
....
}