Stok listesindeki ürünleri mouse ile grup listesinin üzerine bırakınca sürüklenen grup adının üzerine bırakılan grup adı olmasını istiyorum ve bunu yapmak için çaba gösteriyorum. Bay uğraştım fakat muvaffak olamadım.
Kod: Tümünü seç
implementation
{$R *.dfm}
type
// A custom DragObject - our controls require it to be inherited from TDragControlObject
// ot better from TcxDragControlObject (cxControls.pas) that is derived from TDragControlObject
TcxDragRowControlObject = class(TcxDragControlObject)
public
DragRecord: Integer;
end;
procedure TForm1.cxDBTreeList1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
SourceView : TcxCustomGridView;
SourceRowID : Variant;
TargetNode : TcxDBTreeListNode;
begin
with Source as TcxDragRowControlObject do
begin
// Obtaining the source GridView
SourceView := (Control as TcxGridSite).GridView;
// Obtaining the target TreeView node
TargetNode := (Sender as TcxDBTreeList).GetNodeAt(x,y);
// TargetNode := TcxTreeListNode GetNodeAt(X, Y);
// Obtaining the source row
SourceRowID := SourceView.DataController.GetRecordId(DragRecord);
// TEST
// ShowMessage(Format('Source Row : %s'#10'Target Node: %s', [VarToStr(SourceRowID), TargetNode.Texts[]]));
end;
end;
procedure TForm1.cxDBTreeList1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
// Only dragging from a Grid View cell is accepted
// We verified this earlier when created our custom DragObject
Accept := (Source is TcxDragRowControlObject) and
((Sender as TcxDBTreeList).GetNodeAt(X, Y) <> nil);
end;
procedure TForm1.cxGridDBTableView1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ClickPoint := Point(X, Y);
end;
procedure TForm1.cxGridDBTableView1StartDrag(Sender: TObject;
var DragObject: TDragObject);
var
AHitTest: TcxCustomGridHitTest;
begin
// To determine over which area the cursor is positioned when drag-and-drop is started
AHitTest := (Sender as TcxGridSite).GridView.ViewInfo.GetHitTest(ClickPoint);
if AHitTest.HitTestCode = htCell then // Record is being dragged
begin
// Creating a custom Drag Object
DragObject := TcxDragRowControlObject.Create(Sender as TControl);
(DragObject as TcxDragRowControlObject).DragRecord := TcxGridRecordCellHitTest(AHitTest).GridRecord.RecordIndex; // Drag record index
end;
end;
Kod: Tümünü seç
[DCC Error] Unit1.pas(102): E2010 Incompatible types: 'TcxDBTreeListNode' and 'TcxTreeListNode'