Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Listview Drag Into Group

Posted on 2009-05-14
1
Medium Priority
?
677 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
EddieShipman earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 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