I have two string grids on a form, sgSelected and sgAvailable.
sgSelected shows:
AM 050620P01
AM 050620P02
PM 050620P03
sgAvailable shows:
050620P01
050620P02
050620P03
050627P04
050627P05
050627P06
I want to have a drag and drop procedure for the user to select a panel from sgAvailable and drop it to a specific cell in sgSelected. I have the following code which always replaces the first cell of information in sgSelected, but what I want is for the information to be replaced in the specific cell it's being dragged to. For instance, if I click on 050627P06 and drag it to the second cell in sgSelected I would want 050620P02 replaced with 050627P06.
Any idea of what I need to do to make this happen? Thanks!
Leslie
sgSelected shows:
AM 050620P01
AM 050620P02
PM 050620P03
sgAvailable shows:
050620P01
050620P02
050620P03
050627P04
050627P05
050627P06
I want to have a drag and drop procedure for the user to select a panel from sgAvailable and drop it to a specific cell in sgSelected. I have the following code which always replaces the first cell of information in sgSelected, but what I want is for the information to be replaced in the specific cell it's being dragged to. For instance, if I click on 050627P06 and drag it to the second cell in sgSelected I would want 050620P02 replaced with 050627P06.
Any idea of what I need to do to make this happen? Thanks!
Leslie
Code:
procedure TfrmChangePanels.sgAvailableSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
Self.SelectedRow := ARow; //SelectedRow public variable integer
sgAvailable.BeginDrag (false,5);
end;
procedure TfrmChangePanels.sgSelectedDragDrop(Sender, Source: TObject; X,
Y: Integer);
var
src: TStringGrid;
dst: TStringGrid;
i : integer;
begin
if (source is TStringGrid) and (sender is TStringGrid) then begin
src := source as TStringGrid;
dst := sender as TStringGrid;
dst.Cells[1, 0] := src.Cells[0, Self.SelectedRow];
end;
end;
procedure TfrmChangePanels.sgSelectedDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Source is TStringGrid;
end;