Fórum Drag-and-drop // Urgentíssimo #165999
23/06/2003
0
Alguem pode me dizer como fazer para realizar uma operação drag-and-drop em um componente ListView?
Quero alternar as linhas manualmente.
Até mais.
Quero alternar as linhas manualmente.
Até mais.
Alex Maia
Curtir tópico
+ 0
Responder
Posts
23/06/2003
Cdaraujo
Caro amigo,
Veja um exemplo muito legal que preparei para atender justamente o que vc tava procurando.
Atenciosamente
Daniel Araújo
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
Button1: TButton;
procedure ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
procedure Button1Click(Sender: TObject);
procedure ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{Este exmplo faz que o ListBox2 fique com o valor que originou o arraste. Somente a ListBox1}
{deve ter a propriedade DRAGMODE=AUTOMATIC}
procedure TForm1.ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
TListBox(Sender).Items.Add(TListBox(Source).Items[TListBox(Source).ItemIndex]);
TListBox(Source).Items.Delete(TListBox(Source).ItemIndex);
TListBox(Sender).ItemIndex := TListBox(Sender).Items.Count -1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Add(´Daniel´);
end;
procedure TForm1.ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source is TListBox;
end;
end.
[quote:89556cd07b=´Alex Maia´]Alguem pode me dizer como fazer para realizar uma operação drag-and-drop em um componente ListView?
Quero alternar as linhas manualmente.
Até mais.[/quote:89556cd07b]
Veja um exemplo muito legal que preparei para atender justamente o que vc tava procurando.
Atenciosamente
Daniel Araújo
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
Button1: TButton;
procedure ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
procedure Button1Click(Sender: TObject);
procedure ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{Este exmplo faz que o ListBox2 fique com o valor que originou o arraste. Somente a ListBox1}
{deve ter a propriedade DRAGMODE=AUTOMATIC}
procedure TForm1.ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
TListBox(Sender).Items.Add(TListBox(Source).Items[TListBox(Source).ItemIndex]);
TListBox(Source).Items.Delete(TListBox(Source).ItemIndex);
TListBox(Sender).ItemIndex := TListBox(Sender).Items.Count -1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Add(´Daniel´);
end;
procedure TForm1.ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source is TListBox;
end;
end.
[quote:89556cd07b=´Alex Maia´]Alguem pode me dizer como fazer para realizar uma operação drag-and-drop em um componente ListView?
Quero alternar as linhas manualmente.
Até mais.[/quote:89556cd07b]
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)