In dbgrideh, multiple rows are allowed. How can I know which rows are selected?
Is a bookmark type attribute.
Selectedrows: tbookmarklist
Procedure tform1.button1click (Sender: tobject );
VaR
I, J: integer;
S: string;
Begin
If dbgrid1.selectedrows. Count> 0 then
With dbgrid1.datasource. dataset do
For I: = 0 to dbgrid1.selectedrows. Count-1 do
Begin
Gotobookmark (pointer (dbgrid1.selectedrows. items [I]);
For J: = 0 to FieldCount-1 do
Begin
If (j> 0) Then S: = S + ',';
S: = S + fields [J]. asstring;
End;
Listbox1.items. Add (s );
S: = '';
End;
End;
After multiple rows are selected on dbgrideh, you must add all the selected records to a fixed table in the SQL database.
Dbgrideh. selectedrows records the bookmark of all selected rows. selectedrows and gotobookmark are used. Code As follows:
Procedure tform1.button1click (Sender: tobject );
VaR
I, J: integer;
S: string;
Begin
If dbgrid1.selectedrows. Count> 0 then
With dbgrid1.datasource. dataset do
For I: = 0 to dbgrid1.selectedrows. Count-1 do
Begin
Gotobookmark (pointer (dbgrid1.selectedrows. items [I]);
For J: = 0 to FieldCount-1 do
Begin
If (j> 0) Then S: = S + ',';
S: = S + fields [J]. asstring;
end;
listbox1.items. add (s);
S: = '';
end;