Delphi DBGrid Record selection and reverse selection drag processing

Source: Internet
Author: User

Dbgrid1.dragmode: = dmmanual;//Note that this setting does not change

Procedure Applicationevents1message (var msg:tagmsg; var handled:boolean);

Procedure Tform18.applicationevents1message (Var msg:tagmsg;
var handled:boolean);
Begin
Case Msg.message of
Wm_lbuttondown:
Begin
If Msg.hwnd = Dbgrid1.handle Then
Begin
Dbgrid1.perform (Msg.message, Msg.wparam, Msg.lparam);
Dbgrid1.dragmode: = dmautomatic;
End
End
WM_LBUTTONUP:DBGrid1.DragMode: = dmmanual;
End
End

---------------------------------------------------------------

Procedure Tform10.speedbutton7click (Sender:tobject);

Select All

Begin
With DBGrid1.datasource.dataset do
Begin
First;
While not DM. Aq_personal. EOF do
Begin
DBGrid1.SelectedRows.CurrentRowSelected: = True;
Dm. Aq_personal. Next;
End
End
End

Procedure Tform10.speedbutton8click (Sender:tobject);//Reverse Selection
Var
I:integer;
Saveplace:tbookmarklist;
Begin
DBGrid1.DataSource.DataSet.DisableControls;
For I:=1 to DBGrid1.DataSource.DataSet.RecordCount do
Begin
Dbgrid1.datasource.dataset.recno:=i;
Dbgrid1.selectedrows.currentrowselected:=not DBGrid1.SelectedRows.CurrentRowSelected;
End
Saveplace:=dbgrid1.selectedrows;
DBGrid1.DataSource.DataSet.GotoBookmark (Pointer (saveplace[0]));//point pointer to the first record of the current selection
DBgrid1.DataSource.DataSet.EnableControls;
End

Delphi DBGrid Record selection and reverse selection drag processing

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.