Solved

Listview Drag Into Group

Posted on 2009-05-14
1
636 Views
Last Modified: 2012-05-07
Hi, I'd liketo me able to Drag a listview item into a listview Group

for example I have 2 groups, I grad 1 item into the second group

this is what I'm using for dragging.

procedure TFrame2.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
  currentItem, nextItem, dragItem, dropItem : TListItem;
begin
  if Sender = Source then
  begin
    with TListView(Sender) do
    begin
      dropItem := GetItemAt(X, Y) ;
      currentItem := Selected;
      while currentItem <> nil do
      begin
        nextItem := GetNextItem(currentItem, SdAll, [IsSelected]) ;
        if Assigned(dropItem) then
          dragItem := Items.Insert(dropItem.Index)
        else
          dragItem := Items.Add;
        dragItem.Assign(currentItem) ;
        currentItem.Free;
        currentItem := nextItem;
      end;
    end;
  end;

end;

procedure TFrame2.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Sender = ListView1;
end;





and from what I can tell this is for changing the item to a different group. the below will move the selected item into the second group.

listview1.Items.Item[listview1.Selected.Index].GroupID:=1;



I'm needing that to be merged within the drag.


there is also this function

function MoveListViewItem(ListView: TListView; ItemFrom, ItemTo: Word): Boolean;
var
  Source, Target: TListItem;
begin
  listview.Items.BeginUpdate;
  try
    Source := ListView.Items[ItemFrom];
    Target := ListView.Items.Insert(ItemTo);
    Target.Assign(Source);
    Target.Selected := True;
    Source.Free;
    Result := True;
  finally
    ListView.Items.EndUpdate;
  end;
end;
 
//Move Down
 if ListView1.Selected <> nil then
  MoveListViewItem(ListView1, ListViewIP1.Selected.Index, ListView1.Selected.Index + 2);
 
//Move Up
 if ListView1.Selected <> nil then
  MoveListViewItem(ListView1, ListView1.Selected.Index, ListView1.Selected.Index -1);


0
Comment
Question by:eNarc
1 Comment
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 24396565
Can't you just check the GroupID of dropItem and then set the GroupID of dragItem to the same?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now