Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DbGrid : OnMouseDown / drag and drop in D5

224 views
Skip to first unread message

Mert Demir

unread,
Oct 14, 1999, 3:00:00 AM10/14/99
to
Hi folks;
I'm trying to drag & drop from a DbGrid. From what I learned from previous
posts I put a

BeginDrag(False,10)

in OnMouseDown event of DbGrid ( which was hidden in D4, surfaced in D5).

BUT : OnMouseDown only fires when the user clikcs on the non-client are ONLY
(i.e. headers, scrollbars etc.) but not the rows.

Could anyone explain how to start dragging from DbGrid ? (The OnClick event
doesn't work because I want the row be selected - naturally - on that
event). I also set the editing of dbgrid to false because clicking on any
row puts the field in edit mode.

Thanks in advance

John Elrick

unread,
Oct 14, 1999, 3:00:00 AM10/14/99
to
You could try setting DragMode to automatic, that works fine in D3. But
there could have been changes to D5.

John


Mert Demir <mcd...@facstaff.wisc.edu> wrote in message
news:7u4mop$rg...@forums.borland.com...

Mert Demir

unread,
Oct 15, 1999, 3:00:00 AM10/15/99
to
Well this doesn't work since in that case a mouse click starts the dragging
operation whereas it should select a record.
Thanks.

John Elrick wrote in message <7u54it$18...@forums.borland.com>...

John Elrick

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
Sorry about that, chief. I just ran a quick test and this should do what
you desire:

procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
DBGrid1.BeginDrag(False);
end;

That's with the mode set to dmManual.

Drag mode starts after you've moved the mouse (with the button down) more
than 5 pixels.

John

Mert Demir <mcd...@facstaff.wisc.edu> wrote in message

news:7u7bhq$kd...@forums.borland.com...

John Elrick

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
PS. I tested this in D3, don't know if changes have been made so it won't
work in D5.

John


John Elrick <jo...@improgrammer.com> wrote in message
news:7ufkid$s6...@forums.borland.com...

John Elrick

unread,
Oct 19, 1999, 3:00:00 AM10/19/99
to
Was just informed of something and tested it. This won't work. It produces
a Click Drag effect, not what you want.

John Elrick

unread,
Oct 19, 1999, 3:00:00 AM10/19/99
to
Thanks to Victor Arakcheev for giving me the idea to use an RxDBGrid.

procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
Edit1.Text := FMyField.AsString;
end;

procedure TForm1.DBGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DBGrid1.BeginDrag(False);
FMyField := DBGrid1.SelectedField;
end;

procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := True;
end;

DBGrid1 is an TRxDBGrid in this instance.


FWIW

0 new messages