1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram

  5. Delphifan Magazine
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Work with Grids

Discussion in 'Delphi Programming' started by saedi_mehdi, Dec 4, 2013.

  1. saedi_mehdi
    Offline

    saedi_mehdi DF Junior

    How can we select multiple rows with Shift in DBGrid?is true this Coding?


    property BM2: TBookmark read FBM2 Write SetBM2;

    procedure Markieren(Sender: TObject);
    function Shiftgedr: Boolean;


    procedure TForm1.Markieren(Sender: TObject);
    var
    Richtung: string;
    TempBM: TBookmark;
    begin
    with (Sender as TDBGRID).DataSource.Dataset do
    begin
    if (BOF and EOF) then
    Exit;
    DisableControls;
    try
    try
    GotoBookmark(BM1);
    case DBGrid1.DataSource.DataSet.CompareBookmarks(BM1, BM2) of
    -1: Richtung := 'Unten';
    1: Richtung := 'Oben';
    0: Richtung := 'Gleich';
    end;
    TempBM := DBGrid1.DataSource.DataSet.GetBookmark;
    while DBGrid1.DataSource.DataSet.CompareBookmarks(BM2, TempBM) <> 0 do
    begin
    DBGrid1.SelectedRows.CurrentRowSelected := True;
    if Richtung = 'Unten' then
    Next
    else
    Prior;
    TempBM := DBGrid1.DataSource.DataSet.GetBookmark;
    end;
    finally
    FreeBookmark(tempbm);
    end;
    finally
    EnableControls;
    end;
    end;
    end;

    function TForm1.Shiftgedr: Boolean;
    var
    State: TKeyboardState;
    begin
    GetKeyboardState(State);
    Result := ((State[VK_SHIFT] and 128) <> 0);
    end;

    begin
    if not Shiftgedr then
    Merke1 := nil;

    if Merke1 = nil then
    Merke1 := DBGrid1.DataSource.DataSet.GetBookmark
    else
    Merke2 := DBGrid1.DataSource.DataSet.GetBookmark;

    if (Merke1 <> nil) and (Merke2 <> nil) then
    begin
    if Shiftgedr then
    begin
    Markieren(Sender);
    end;
    end;
    end;
     

Share This Page