hej
Dec 30 2003, 05:21 AM
Hi
Anyone know an easy way to print selected rows from DBgrids.
Henning
basswar
Jan 20 2004, 09:31 AM
Create temporary table, insert the PK's iterating on the Grid's SelectedRows property,
and let the report based on the JOIN between the temporary and the displayed dataset.
Regards:Alex
llutti
Jan 22 2004, 05:42 AM
Hi,
I think the better way to solve this problem is:
- To create an array or a list with all numbers of rows is selected in your dbgrid
- To create a frUserDataset to control the navigation in your array
- In report event onGetValue you can access the row in dbgrid using the array like an index
I had use this way to solve similar problem, but with stringgrid an works fine and faster.
Regards
Luciano
Schreij
Jan 23 2004, 08:01 AM
I once used the method Alex described
I have a (Client)Dataset showed in de DBGrid.
I show some fields for selection (and there is a field FieldID wich is not shown).
There is also a (ADO) temp table and a sql-string for using in this table (the sql is without the where part)
| CODE |
procedure TForm1.ButtonPrintClick(Sender: TObject); var i: Integer; S: string; BML: TBookmarkList; begin BML:= DBGrid1.SelectedRows; if BML.Count = 0 then //no records Abort; S:= ''; with DBGrid1.DataSource.DataSet do begin DisableControls; try for i:= 0 to BML.Count-1 do begin Bookmark:= BML[i]; S:= S + ', '+FieldByName('FieldID').AsString; end;//for finally EnableControls; end;//try-finally end;//with Delete(S, 1,1);//delete 1th comma with DM.AdsTmp do begin Close; CommandText:= sSQL + 'AND TheID IN ('+S+') '; //ORDER BY ... Open; //Print AdsTmp end; end;
|
The FastReport part is not so difficult when you have a good SQL, with a field for each showed memo.
pele
Jun 11 2010, 07:08 AM
But how to this without removing NOT selected rows from dataset ?
I have to print selected rows and just skip/jump/no print other
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.