R
redweek
Unregistered / Unconfirmed
GUEST, unregistred user!
Dbgrid控件多重选择的怪问题。BookMarkList,BookMark,使用书签,用的ADOQuery控件。100分送上,急阿!!!请高手帮忙! ( 积分: 100 )<br />procedure TForm_ContinuPrnt.BitB_PrintClick(Sender: TObject);
Var
i,x:Integer;
BookMarkList:TBookMarkList ;
BookMark:TBookMark;
getClientCode,getPre,getThis,getFact,getPrice,getMoney,getName:String;
begin
With MyDataModule do
Begin
AQ_DataKeep.Close;
AQ_DataKeep.SQL.Clear;
AQ_DataKeep.SQL.Add('Select a.ClientCode,a.Years,a.Months,a.PreData,a.Thisdata,a.FactData,a.Price,a.AmountMoney,a.PrintMask,a.BankDeduct,b.ClientNo,b.ClientCode,b.AreaNo,b.UseName');
AQ_DataKeep.SQL.Add('From EdataKeep a,EClientInfo b');
AQ_DataKeep.SQL.Add('Where (a.ClientCode=b.ClientCode) And (b.AreaNo=AA) And (a.Years=YY) And (a.Months=MM)');
AQ_DataKeep.SQL.Add('Order By b.ClientNo');
AQ_DataKeep.Parameters.ParamByName('pAA').Value:=getAreaNo;
AQ_DataKeep.Parameters.ParamByName('pYY').Value:= getYear;
AQ_DataKeep.Parameters.ParamByName('pMM').Value:= getmonth;
AQ_DataKeep.Prepared;
AQ_DataKeep.Open;
BookMark:=AQ_DataKeep.GetBookmark ; //....获得书签.......
BookmarkList:=Dbgrid1.SelectedRows; //。。。该行也有问题
x:=BookmarkList.Count; //。。。该行有问题,结果总是 0
Try
For i:=0 to BookmarkList.Count-1 do //因为BookmarkList.Count 总是0 ,程序不能对网格中选择的多行数据操作
begin
AQ_DataKeep.GotoBookmark(Pointer(Dbgrid1.SelectedRows));
getClientCode:=AQ_DataKeep.FieldByname('ClientCode').AsString;
getPre:=AQ_DataKeep.FieldByname('PreData').AsString;
getThis:=AQ_DataKeep.FieldByname('ThisData').AsString;
getFact:=AQ_DataKeep.FieldByname('FactData').AsString;
getPrice:=AQ_DataKeep.FieldByname('Price').AsString;
getMoney:=AQ_DataKeep.FieldByname('AmountMoney').AsString;
getName:=AQ_DataKeep.FieldByname('useName').AsString;
end;
except
AQ_DataKeep.GotoBookmark(Bookmark) ;
AQ_DataKeep.FreeBookmark(Bookmark) ;
end;
end;
end;
DBgrid控件可以设置了Option中的dgMultiSelect 为true后,就可以在界面上按住Ctrl(contral)键,对网格的数据进行多个选择。对数据多个选择后,可以只对选择的多行数据操作。但是,我用的数据控件是ADOQuery(就是程序中的AQ_DataKeep),因为BookmarkList.Count 总是0 ,程序不能对网格中选择的多行数据操作,请问这是为什么?
我用Ttable控件就一切都正常(数据库是paradox)!用ADOQuery控件(数据库是SQL 2000)就不行,请高手回答!
Var
i,x:Integer;
BookMarkList:TBookMarkList ;
BookMark:TBookMark;
getClientCode,getPre,getThis,getFact,getPrice,getMoney,getName:String;
begin
With MyDataModule do
Begin
AQ_DataKeep.Close;
AQ_DataKeep.SQL.Clear;
AQ_DataKeep.SQL.Add('Select a.ClientCode,a.Years,a.Months,a.PreData,a.Thisdata,a.FactData,a.Price,a.AmountMoney,a.PrintMask,a.BankDeduct,b.ClientNo,b.ClientCode,b.AreaNo,b.UseName');
AQ_DataKeep.SQL.Add('From EdataKeep a,EClientInfo b');
AQ_DataKeep.SQL.Add('Where (a.ClientCode=b.ClientCode) And (b.AreaNo=AA) And (a.Years=YY) And (a.Months=MM)');
AQ_DataKeep.SQL.Add('Order By b.ClientNo');
AQ_DataKeep.Parameters.ParamByName('pAA').Value:=getAreaNo;
AQ_DataKeep.Parameters.ParamByName('pYY').Value:= getYear;
AQ_DataKeep.Parameters.ParamByName('pMM').Value:= getmonth;
AQ_DataKeep.Prepared;
AQ_DataKeep.Open;
BookMark:=AQ_DataKeep.GetBookmark ; //....获得书签.......
BookmarkList:=Dbgrid1.SelectedRows; //。。。该行也有问题
x:=BookmarkList.Count; //。。。该行有问题,结果总是 0
Try
For i:=0 to BookmarkList.Count-1 do //因为BookmarkList.Count 总是0 ,程序不能对网格中选择的多行数据操作
begin
AQ_DataKeep.GotoBookmark(Pointer(Dbgrid1.SelectedRows));
getClientCode:=AQ_DataKeep.FieldByname('ClientCode').AsString;
getPre:=AQ_DataKeep.FieldByname('PreData').AsString;
getThis:=AQ_DataKeep.FieldByname('ThisData').AsString;
getFact:=AQ_DataKeep.FieldByname('FactData').AsString;
getPrice:=AQ_DataKeep.FieldByname('Price').AsString;
getMoney:=AQ_DataKeep.FieldByname('AmountMoney').AsString;
getName:=AQ_DataKeep.FieldByname('useName').AsString;
end;
except
AQ_DataKeep.GotoBookmark(Bookmark) ;
AQ_DataKeep.FreeBookmark(Bookmark) ;
end;
end;
end;
DBgrid控件可以设置了Option中的dgMultiSelect 为true后,就可以在界面上按住Ctrl(contral)键,对网格的数据进行多个选择。对数据多个选择后,可以只对选择的多行数据操作。但是,我用的数据控件是ADOQuery(就是程序中的AQ_DataKeep),因为BookmarkList.Count 总是0 ,程序不能对网格中选择的多行数据操作,请问这是为什么?
我用Ttable控件就一切都正常(数据库是paradox)!用ADOQuery控件(数据库是SQL 2000)就不行,请高手回答!