Drag from ListBox to Edit
Here's how to drag an (string) item from a ListBox to an Edit control:
~~~~~~~~~~~~~~~~~~~~~~~~~
{
Set ListBox.DragMode = dmAutomatic
from the Object Inspector.
Let the OnDragOver and OnDragDrop
for the Edit control look like:
}
procedure TForm1.Edit1DragOver
(Sender, Source: TObject;
X,Y: Integer; State:TDragState;
var Accept: Boolean) ;
begin
Accept := True;
end;
procedure TForm1.Edit1DragDrop
(Sender, Source: TObject; X,Y: Integer) ;
begin
(Sender as TEdit).Text :=
(Source as TListBox).Items
[(Source as TListBox).ItemIndex]
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Here are some more dragging and dropping related articles.
Delphi tips navigator:
» Hide another application
« Associate an application with a file extension
~~~~~~~~~~~~~~~~~~~~~~~~~
{
Set ListBox.DragMode = dmAutomatic
from the Object Inspector.
Let the OnDragOver and OnDragDrop
for the Edit control look like:
}
procedure TForm1.Edit1DragOver
(Sender, Source: TObject;
X,Y: Integer; State:TDragState;
var Accept: Boolean) ;
begin
Accept := True;
end;
procedure TForm1.Edit1DragDrop
(Sender, Source: TObject; X,Y: Integer) ;
begin
(Sender as TEdit).Text :=
(Source as TListBox).Items
[(Source as TListBox).ItemIndex]
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Here are some more dragging and dropping related articles.
Delphi tips navigator:
» Hide another application
« Associate an application with a file extension
Source...