드래그 할 때 화면에 내 컨트롤을 표시하고 싶습니다.
private void flowLayoutPanel1_DragEnter(object sender, DragEventArgs e)
{
FlowLayoutPanel _destination = (FlowLayoutPanel)sender;
e.Effect = _destination.Controls.GetChildIndex(_destination.GetChildAtPoint(_destination.PointToClient(new Point(e.X, e.Y)))) >= 0 ? DragDropEffects.Move : DragDropEffects.None;
foreach (Control control in flowLayoutPanel1.Controls)
{
List <Bitmap> controlsImgs = new List<Bitmap>();
Rectangle controlsRect = new Rectangle(e.X,e.Y,control.Width,control.Height);
Bitmap b = new Bitmap(control.Width, control.Height);
control.DrawToBitmap(b, new Rectangle(0, 0, b.Width, b.Height));
controlsImgs.Add(b);
}
for (int i = 0; i < controlsImgs.Count; i++)
{
//TODO
}
}
다음은 FlowLayoutPanel
패널 인 일부 컨트롤을 끌어서 놓을 수 있는 , foreach 문에서 각 컨트롤이 비트 맵 이미지로 변환되기를 원하므로 드래그 할 때 DragEnter
컨트롤 스크린 샷을 표시 할 수 있습니다. 내가 올바르게 수행했다고 생각하고 먼저 Bitmap
이미지 목록을 정의한 다음 너비와 높이를 제어하는 새 비트 맵을 만든 다음 해당 비트 맵을 내 controlsImgs
목록에 추가했습니다 . 이제 for 루프에서 각 컨트롤 이미지를 화면에 그려야합니다. 그렇게하는 방법 ? 해당 컨트롤의 위치는 마우스 위치와 동일하며 위치를 의미합니다 e
.
Control.DrawToBitmap을 사용하십시오 . ( 여기 에서 예를 참조 하십시오 .)
새 커서를 설정하려면 GiveFeedback 이벤트를 사용하십시오 . 하다:
e.UseDefaultCursors = false;
Cursor.Current = MyCursor;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다