Multi-row selection for the dbgrideh control in ehlib

Source: Internet
Author: User
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.