Jump to content


Photo

move items around inside nextgird via drag & drop ?

move drag drop dragmode

  • Please log in to reply
2 replies to this topic

#1 d6user

d6user
  • Members
  • 94 posts

Posted 26 August 2014 - 05:59 AM

after using a simple listbox control in one of my projects, i decided to convert it to a nextgrid so that i could do more fancy stuff. this listbox was for entering parameters for a dos console application that only accepts command line parameters. one of the features that i incorporated into this standard listbox was the ability to move the items around (up/down) through drag and drop. this worked out great because users could now move the parameters in whatever order they desire.


below, is the code i use for the standard listbox. it works pefectly. however, i can't seem to get it to work in the nextgrid. i search around this forum and then google for an answer, but did not find one.

var
Form1: TForm1;
StartingPoint : TPoint;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject) ;
begin
ListBox1.DragMode := dmAutomatic;
end;

procedure TForm1.listbox1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
DropPosition, StartPosition: Integer;
DropPoint: TPoint;
begin
DropPoint.X := X;
DropPoint.Y := Y;
with Source as TListBox do
begin
StartPosition := ItemAtPos(StartingPoint,True);
DropPosition := ItemAtPos(DropPoint,True);
Items.Move(StartPosition, DropPosition);
end;
end;

procedure TForm1.listbox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
StartingPoint.X := X;
StartingPoint.Y := Y;
end;

procedure TForm1.listbox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source = listbox1; // <-- listbox control
end;


#2 d6user

d6user
  • Members
  • 94 posts

Posted 01 September 2014 - 04:11 AM

solved

i did not know that nextgrid includes the feature of drag/drop automatically (by clicking the row to drag to another row, nextgrid displays a red bar over the row to indicate it is in drag mode for that line) and to my knowledge, this is not mention in the documentation or it is hidden somewhere. anyway. as long as i keep the [DragMode] property set to dmManual, the drag/drop of rows does what i need, perfectly.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 September 2014 - 07:43 PM

Hi,

Sorry for delay. In v6 it will be even better (already finished it). You will be able to drag and drop into parent items.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users