Description:
I use the TcxPageControl and I want to move pages using drag&drop. When I start the dragging, I save the PageIndex property value of the dragged page with the help of the OnStartDrag event using the ActivePageIndex property. But how can I determine the PageIndex of the page I want to “replace” if I use the OnEndDrag event?
Answer:
Basically, you may use the PageControl's IndexOfTabAt method to determine the TabSheet the mouse pointer is over. Here is some sample code:
Delphiprocedure TForm1.cxPageControl1DragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
var
Index: Integer;
begin
with TcxPageControl(Sender) do
begin
Index := IndexOfTabAt(X, Y);
// your code here
end;
end;