µçÄÔ¹ÊÕÏ

λÖãºITÂäÎéÕß >> µçÄÔ¹ÊÕÏ >> ä¯ÀÀÎÄÕÂ

WinFormµÄÊó±êÍÏק¹¦ÄÜ


·¢²¼ÈÕÆÚ£º2022/12/31
 

WinFormµÄÊó±êÍÏק¹¦ÄÜ

¹¦ÄÜ ´Ë´úÂëʵÏÖµÄÊÇ´Ó×ÊÔ´¹ÜÀíÆ÷´°¿ÚÑ¡ÖÐÒ»¸ö»ò¶à¸öÎļþÍÏÈëWinForm´°ÌåÖÐWinFormºǫ́´úÂë±ä»áµÃµ½±»ÍÏÈëµÄÎļþÁбí

˼· ͨ¹ýDragEnterʼþ»ñµÃ±»ÍÏÈë´°¿ÚµÄÐÅÏ¢£¨¿ÉÒÔÊÇÈô¸ÉÎļþһЩÎÄ×ֵȵȣ©ÔÚDragDropʼþÖжÔÐÅÏ¢½øÐнâÎö

»­ÃæÉè¼Æ

´°ÌåµÄAllowDropÊôÐÔ±ØÐëÉèÖóÉtrue

ÇÒ±ØÐëÓÐDragEnterʼþ£¨µ¥¶ÀдDragDropʼþÊDz»»á¾ßÓÐÍÏק¹¦Äܵģ©

»­ÃæµÄDesigner Code(frmMainDesignercs)

//

// frmMain

//

thisAllowDrop = true;

thisDragDrop += new SystemWindowsFormsDragEventHandler(thisfrmMain_DragDrop);

thisDragEnter += new SystemWindowsFormsDragEventHandler(thisfrmMain_DragEnter);

//

// dgv

//

thisdgvAllowDrop = true;

thisdgvDragEnter += new SystemWindowsFormsDragEventHandler(thisfrmMain_DragEnter);

thisdgvDragDrop += new SystemWindowsFormsDragEventHandler(thisfrmMain_DragDrop);

FormµÄºǫ́´úÂë

ÖØÒª´úÂë eEffect = DragDropEffectsLink;

£¨×¢ DragDropEffectsö¾ÙÀàÐÍ»¹ÓÐÆäËûÖµÓÐÐËȤµÄ¿ÉÒÔ²ÎÕÕMSDNµÄ°ïÖú

us/library/systemwindowsformsdragdropeffectsaspx £©

WinForm&DataGridViewʼþ

#region DragEnter(Form&DataGridView)

/// <summary>

/// DragEnter

/// </summary>

/// <param name=sender></param>

/// <param name=e></param>

private void frmMain_DragEnter(object sender DragEventArgs e)

{

//ÒÔϤÎÎĤ¬¤Ê¤±¤ì¤Ð¡¸frmMain_DragDrop¡¹¤âÒÛ¤ËÁ¢¤¿¤Ê¤¯¤Ê¤ë

eEffect = DragDropEffectsLink;

}

#endregion

#region DragDrop(Form&DataGridView)

/// <summary>

/// DragDrop

/// </summary>

/// <param name=sender></param>

/// <param name=e></param>

private void frmMain_DragDrop(object sender DragEventArgs e)

{

DataDisplay(e);

thisActivate();

}

#endregion

ÉÏһƪ£º¿Í»§¶Ë·ÃÎÊWeb Service·½·¨µÄÒ»¸öϸ½Ú

ÏÂһƪ£º±í¸ñ¿Ø¼þSpread Studio 7ÉÏÏß