简体   繁体   中英

How do I handle drag-and-drop in the designer?

I've created a control, DataGridViewContainer , that fakes partial-line scrolling in a DataGridView - basically it's a panel and a scrollbar and a few event handlers. I'd like to be able to use DataGridViewContainer at design time, dragging a DataGridView onto it to set its .DataGridView property to the dragged control. How do I handle drag-and-drop in the designer?

If you want to be able to drag a datagridview (or any other object in fact), your usercontrol needs to be configured to act as a container,

A simple example a control acting as a container

Alternatively, and what I would reccomend, is that if each container will always contain a single datagridview, just add a datagridview to the usercontrol at design time (the usercontrol designer, not the form containing the control). You can set properties in the usercontrol to expose the relevant properties that you'll need to change.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM