delphi 中如何把listbox1选中的item项拖到Edit1中,谢谢
2个回答
展开全部
//一下代码通过编译。
procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if source is Tlistbox then
Accept:=true;
end;
procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (sender is Tedit) and (source is Tlistbox)then
begin
edit1.Text :=listbox1.Items.Strings[listbox1.itemIndex];
listbox1.DeleteSelected ;
end;
end;
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft then
(sender as tlistbox).BeginDrag(false);
end;
procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if source is Tlistbox then
Accept:=true;
end;
procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (sender is Tedit) and (source is Tlistbox)then
begin
edit1.Text :=listbox1.Items.Strings[listbox1.itemIndex];
listbox1.DeleteSelected ;
end;
end;
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft then
(sender as tlistbox).BeginDrag(false);
end;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询