请问关于DbGrid 得取选中行的一个字段数据数据(多选),而DbGird不要乱滚动。 selectIndex.clear;
adqQuery.DisableControls();
for i := 0 to selectCount - 1 do
begin
adqQuery.Book := ehDbgCommon.SelectedRows[i];
selectIndex.Add(IntToStr(adqQuery.fieldByName('index').AsInteger));
end;
adqQuery.EnableControls();
这样可以实现取出选中列的数据,但是,DbGrid的节目显示回把选中的最后一条记录移动到DbGrid的中间来。看起来就是一跳一跳的
我试着用一个后台的AdqQuery就是不连接的DbGrid的来作这个事儿,可是book好像不能用后台的AdoQuery上。
望各位指点一二,谢谢了先。。不知道我表达清楚木有?分不够再加
adqQuery.DisableControls();
for i := 0 to selectCount - 1 do
begin
adqQuery.Book := ehDbgCommon.SelectedRows[i];
selectIndex.Add(IntToStr(adqQuery.fieldByName('index').AsInteger));
end;
adqQuery.EnableControls();
这样可以实现取出选中列的数据,但是,DbGrid的节目显示回把选中的最后一条记录移动到DbGrid的中间来。看起来就是一跳一跳的
我试着用一个后台的AdqQuery就是不连接的DbGrid的来作这个事儿,可是book好像不能用后台的AdoQuery上。
望各位指点一二,谢谢了先。。不知道我表达清楚木有?分不够再加
贴子错别字过多者,扣除信誉分5分!楼主小心哪!
x,i,countmy:integer;
BookList: TBookList;
TempBook: TBook;
begin
if show_mode='1' then
begin
DBGrid1DblClick(Sender);
exit; //零售暂时不支持多行选择
end;if not dmmain.DSquery.Active then
begin
if dbgrid1.SelectedRows.Count < 1 then
Application.MessageBox('请指定出售的商品',pchar(application.Title),mb_iconinformation);
exit;
end;
DBGrid1.Datasource.Dataset.DisableControls; if show_mode='2' then
begin
countmy :=fmScrap.sgorder.RowCount ;
if fmScrap.sgorder. Cells[1,countmy-1] = '' then ///最后一行为新增加的新行 2004-4-14 add
countmy := countmy -1;
with DBgrid1.SelectedRows do
if Count > 0 then
begin
fmScrap.sgorder.RowCount := countmy + count; //modify ydy
TempBook:= DBGrid1.Datasource.Dataset.GetBook; for x:= 0 to Count - 1 do
begin
if IndexOf(Items[x]) > -1 then
begin
DBGrid1.Datasource.Dataset.Book:= Items[x];
//得到选定的数据 with fmScrap do
begin
with sgorder do
begin
cells[0,countmy + x] := inttostr(countmy+ x);
Cells[1,countmy + x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_NO').AsString);
Cells[2,countmy + x] := trim(DBGrid1.Datasource.Dataset.Fieldbyname('Goods_Name').AsString);
Cells[3,countmy + x] := trim(DBGrid1.Datasource.Dataset.fieldbyname('singleprice').AsString);
Cells[8,countmy + x]:=trim(DBGrid1.Datasource.Dataset.fieldbyname('baseprice').AsString);//成本假
StockNum_List.Add(trim(DBGrid1.Datasource.Dataset.fieldbyname('Stock_amount').AsString));
end;
end; end;
end;
DBGrid1.Datasource.Dataset.GotoBook(TempBook);
DBGrid1.Datasource.Dataset.FreeBook(TempBook);
end else
begin
DBGrid1.Datasource.Dataset.EnableControls;
Application.MessageBox('您没有选择商品,请选定商品!',pchar(application.Title),mb_iconinformation);
exit;
end;
end;
不好意思,我用的紫光拼音哈。to 白雪:
用bookMark 好像还是不能解决问题滴,还是会抖动一下。啊