How to Drag and Drop a column between 2 ASG?

I am using AdvStringGrid 7.2.8.3 and C++Builder XE4 I am working on the VCL 32 bit platform. My registration is current.



I have two ASG side by side. Is it possible to drag and drop a column from one ASG to the other. I have been working with the settings for DragAndDropSettings and the clipboard settings but I can not make this work. Is it possible?



Thanks

Patrick

I have found one possible alternative to column Drag and Drop. This is to select a column and paste the column into the second ASG. When I do this the top fixed cell in the column does not copy paste. If you can tell me how to make the fixed cell at the top of the column copy/paste with the rest of the column then I think I will have a working solution.



Thanks

Patrick   

Please see TAdvStringGrid demo 28 that demonstrates how you can do column drag & drop.

I have compiled the Delphi sample 28 in C++Builder and it runs correctly as Delphi code.



When create a new C++Builder project and convert the Delphi code to C++ I can not get the OLE Events to trigger.   Below is my project essentials. Can you see any reason why the Ole Events don't trigger?



I have read the sample web page here

http://www.tmssoftware.com/site/asg28.asp





Here is my OLE settings

OleAcceptFiles=true

OleAcceptText=true

OleAcceptURLs=true

OleAppendRows=false

OleCollumnDragDrop=true

OleColumnReorder=false

OleColumnsOnly=false

OleCoppyAlways=false

OleDropRTF=false

OleDropSource=true

OleDropTarget=true

OleEntireRow=false

OleInsertRows=false

OleRemoveRows=false

ShowCells=true



AlowClipboardAlways=true



AllowClipboardColGrow=true

AllowClipboardRowGrow=true



ExcelClipboardFormat=true;



//----H File-----

public:          // User declarations

     __fastcall TForm1(TComponent* Owner);



   TAdvStringGrid *MyASG_ColSource;

   TAdvStringGrid MyASG_ColTarget;

   int MyColSourceIdx;







void __fastcall TForm1::AdvStringGrid3OleDrag(TObject Sender, int ARow, int ACol,

           UnicodeString data, bool &Allow)

{

MyASG_ColSource = dynamic_cast<TAdvStringGrid
>(Sender);

MyColSourceIdx = ACol;

}

//---------------------------------------------------------------------------



void __fastcall TForm1::AdvStringGrid3OleDragOver(TObject Sender, int ARow, int ACol,

           bool &Allow)

{

TAdvStringGrid
MySender = dynamic_cast<TAdvStringGrid
>(Sender);

if(MySender){

     Allow = (MySender != MyASG_ColSource) && (ACol = 0) && ((ACol > 0) || (MySender->ColCount == 1));

}

}

//---------------------------------------------------------------------------



void __fastcall TForm1::AdvStringGrid2OleDragStart(TObject Sender, int ARow, int ACol)



{

MyASG_ColSource = dynamic_cast<TAdvStringGrid
>(Sender);

MyColSourceIdx = ACol;

}

//---------------------------------------------------------------------------



void __fastcall TForm1::AdvStringGrid2OleDragStop(TObject Sender, int OLEEffect)



{

if(OLEEffect == DROPEFFECT_MOVE ){

     MyASG_ColSource->RemoveCols(MyColSourceIdx, 1);

}

}

//---------------------------------------------------------------------------



void __fastcall TForm1::AdvStringGrid2OleDropCol(TObject Sender, int ARow, int ACol,

           int DropCol)

{

MyASG_ColTarget = dynamic_cast<TAdvStringGrid
>(Sender);

TStringList
sl = new TStringList;

sl->Assign( MyASG_ColSource->Cols[DropCol] );

if(ACol==0){ ACol++; /inc(ACol)/ }

MyASG_ColTarget->InsertCols(ACol, 1);

MyASG_ColTarget->Cols[ACol]->Assign(sl);

delete sl;

}

//---------------------------------------------------------------------------







Is there something special in your app, i.e. things like runtime created grid, use of frames, used on another form etc etc..?

Only thing I'm aware of to take in account is that you need to set OleDropTarget, OIeDropSource = true AFTER the parent for the grid is assigned and has a valid window handle (which is the case when you just drop the grid directly on a VCL form)