校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > asp.net DoDragDrop 方法的使用

asp.net DoDragDrop 方法的使用

熱門標(biāo)簽:銅川小型外呼系統(tǒng)運營商 海外地圖標(biāo)注門市標(biāo) 山西防封卡電銷卡套餐 上海楊浦怎么申請申請400電話 廈門商鋪地圖標(biāo)注 浙江外呼系統(tǒng)怎么安裝 陜西人工外呼系統(tǒng)哪家好 云南外呼電銷機(jī)器人系統(tǒng) 地圖標(biāo)注多個行程
在類庫中的定義為:
復(fù)制代碼 代碼如下:

[UIPermissionAttribute(SecurityAction.Demand, Clipboard = UIPermissionClipboard.OwnClipboard)]
public DragDropEffects DoDragDrop(
Object data,
DragDropEffects allowedEffects
)

其中data參數(shù)為要拖放的數(shù)據(jù),如果拖動操作需要于另一個進(jìn)程的應(yīng)用程序相互操作,data代表的數(shù)據(jù)應(yīng)該是基本托管類(String,BitMap,或MetaFile),或者是實現(xiàn) ISerializable 或IDataObject的對象。 allowedEffects參數(shù)表示拖放的效果,為一個枚舉值(DragDropEffects).返回值也為DragDropEffects枚舉值。
  當(dāng)開始調(diào)用DoDragDrop方法拖動一個數(shù)據(jù)對象時,DoDragDrops在拖放過程中,檢測當(dāng)前光標(biāo)位置下的控件是不是有效的放置目標(biāo)。如果當(dāng)前光標(biāo)下的控件是有效的放置目標(biāo),則GiveFeedBack事件以指定的拖放效果引發(fā)。在檢測當(dāng)前位置光標(biāo)是否為有效的拖放目標(biāo)時,DoDragDrops方法同時跟蹤光標(biāo)位置,鍵盤狀態(tài)和鼠標(biāo)狀態(tài)的更改。
   (1)如果用于移出了一個窗口,則引發(fā)DragLeave事件。
  (2)如果移入了另外一個控件,則引發(fā)該控件的DragEnter事件。
  (3)如果鼠標(biāo)移動,但是停留在一個控件中,則引發(fā)DragOver事件。
如果檢測到更改了鍵盤或者鼠標(biāo)狀態(tài),則引發(fā)拖放源的QueryContinueDrag事件, 并根據(jù)事件的QueryContinueDragEventArgs的Action屬性值確定繼續(xù)拖動,放置數(shù)據(jù)或取消操作。
(1)如果Action屬性指定為Continue,則將引發(fā)DragOver事件。
(2)如果Action屬性指定為Drop,則將放置效果返回給源,以便應(yīng)用程序?qū)?shù)據(jù)進(jìn)行適當(dāng)?shù)牟僮鳎焕纾绻且苿硬僮鳎瑒t剪切數(shù)據(jù)。
(3)如果是DragAction的值為Cancel,則引發(fā)DragLeave事件
從csdn上摘抄一段示例代碼:
  下面的代碼示例演示在兩個 ListBox 控件之間的拖放操作。當(dāng)拖動動作啟動時,該示例調(diào)用 DoDragDrop 方法。在 MouseDown 事件期間,如果從鼠標(biāo)位置起鼠標(biāo)移動的距離大于 SystemInformation..::.DragSize,則啟動拖動動作。IndexFromPoint 方法用于確定在 MouseDown 事件期間要拖動的項的索引。
  該示例還演示如何對拖放操作使用自定義光標(biāo)。該示例要求應(yīng)用程序目錄中存在兩個光標(biāo)文件:3dwarro.cur 和 3dwno.cur,分別用于自定義拖動光標(biāo)和禁止停放光標(biāo)。如果選中 UseCustomCursorsCheckCheckBox,則使用自定義光標(biāo)。自定義光標(biāo)在 GiveFeedback 事件處理程序中設(shè)置。
  鍵盤狀態(tài)在右 ListBox 的 DragOver 事件處理程序中計算,以確定基于 Shift、Ctrl、Alt 或 Ctrl+Alt 鍵的狀態(tài)將發(fā)生哪種拖動操作。放置動作在 ListBox 中發(fā)生的位置也在 DragOver 事件期間確定。如果要放置的數(shù)據(jù)不是 String,則 DragDropEffects 中將把 DragEventArgs.sEffect 設(shè)置為 None。最后,停放狀態(tài)在 DropLocationLabelLabel 中顯示。
  要放置的用于右 ListBox 的數(shù)據(jù)在 DragDrop 事件處理程序中確定,并且在 ListBox 中的適當(dāng)位置添加該 String 值。如果拖動操作移動到窗體邊框的外面,則 QueryContinueDrag 事件處理程序中將取消拖放操作
復(fù)制代碼 代碼如下:

using System;
using System.Drawing;
using System.Windows.Forms;
namespace Snip_DragNDrop
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListBox ListDragSource;
private System.Windows.Forms.ListBox ListDragTarget;
private System.Windows.Forms.CheckBox UseCustomCursorsCheck;
private System.Windows.Forms.Label DropLocationLabel;
private int indexOfItemUnderMouseToDrag;
private int indexOfItemUnderMouseToDrop;
private Rectangle dragBoxFromMouseDown;
private Point screenOffset;
private Cursor MyNoDropCursor;
private Cursor MyNormalCursor;
/// The main entry point for the application.
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public Form1()
{
this.ListDragSource = new System.Windows.Forms.ListBox();
this.ListDragTarget = new System.Windows.Forms.ListBox();
this.UseCustomCursorsCheck = new System.Windows.Forms.CheckBox();
this.DropLocationLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
// ListDragSource
this.ListDragSource.Items.AddRange(new object[] {"one", "two", "three", "four",
"five", "six", "seven", "eight",
"nine", "ten"});
this.ListDragSource.Location = new System.Drawing.Point(10, 17);
this.ListDragSource.Size = new System.Drawing.Size(120, 225);
this.ListDragSource.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ListDragSource_MouseDown);
this.ListDragSource.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.ListDragSource_QueryContinueDrag);
this.ListDragSource.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ListDragSource_MouseUp);
this.ListDragSource.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ListDragSource_MouseMove);
this.ListDragSource.GiveFeedback += new System.Windows.Forms.GiveFeedbackEventHandler(this.ListDragSource_GiveFeedback);
// ListDragTarget
this.ListDragTarget.AllowDrop = true;
this.ListDragTarget.Location = new System.Drawing.Point(154, 17);
this.ListDragTarget.Size = new System.Drawing.Size(120, 225);
this.ListDragTarget.DragOver += new System.Windows.Forms.DragEventHandler(this.ListDragTarget_DragOver);
this.ListDragTarget.DragDrop += new System.Windows.Forms.DragEventHandler(this.ListDragTarget_DragDrop);
this.ListDragTarget.DragEnter += new System.Windows.Forms.DragEventHandler(this.ListDragTarget_DragEnter);
this.ListDragTarget.DragLeave += new System.EventHandler(this.ListDragTarget_DragLeave);
// UseCustomCursorsCheck
this.UseCustomCursorsCheck.Location = new System.Drawing.Point(10, 243);
this.UseCustomCursorsCheck.Size = new System.Drawing.Size(137, 24);
this.UseCustomCursorsCheck.Text = "Use Custom Cursors";
// DropLocationLabel
this.DropLocationLabel.Location = new System.Drawing.Point(154, 245);
this.DropLocationLabel.Size = new System.Drawing.Size(137, 24);
this.DropLocationLabel.Text = "None";
// Form1
this.ClientSize = new System.Drawing.Size(292, 270);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.ListDragSource,
this.ListDragTarget, this.UseCustomCursorsCheck,
this.DropLocationLabel});
this.Text = "drag-and-drop Example";
this.ResumeLayout(false);
}
private void ListDragSource_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
// Get the index of the item the mouse is below.
indexOfItemUnderMouseToDrag = ListDragSource.IndexFromPoint(e.X, e.Y);
if (indexOfItemUnderMouseToDrag != ListBox.NoMatches) {
// Remember the point where the mouse down occurred. The DragSize indicates
// the size that the mouse can move before a drag event should be started.
Size dragSize = SystemInformation.DragSize;
// Create a rectangle using the DragSize, with the mouse position being
// at the center of the rectangle.
dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width /2),
e.Y - (dragSize.Height /2)), dragSize);
} else
// Reset the rectangle if the mouse is not over an item in the ListBox.
dragBoxFromMouseDown = Rectangle.Empty;
}
private void ListDragSource_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) {
// Reset the drag rectangle when the mouse button is raised.
dragBoxFromMouseDown = Rectangle.Empty;
}
private void ListDragSource_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if ((e.Button MouseButtons.Left) == MouseButtons.Left) {
// If the mouse moves outside the rectangle, start the drag.
if (dragBoxFromMouseDown != Rectangle.Empty
!dragBoxFromMouseDown.Contains(e.X, e.Y)) {
// Create custom cursors for the drag-and-drop operation.
try {
MyNormalCursor = new Cursor("3dwarro.cur");
MyNoDropCursor = new Cursor("3dwno.cur");
} catch {
// An error occurred while attempting to load the cursors, so use
// standard cursors.
UseCustomCursorsCheck.Checked = false;
}finally {
// The screenOffset is used to account for any desktop bands
// that may be at the top or left side of the screen when
// determining when to cancel the drag drop operation.
screenOffset = SystemInformation.WorkingArea.Location;
// Proceed with the drag-and-drop, passing in the list item.
DragDropEffects dropEffect = ListDragSource.DoDragDrop(ListDragSource.Items[indexOfItemUnderMouseToDrag], DragDropEffects.All | DragDropEffects.Link);
// If the drag operation was a move then remove the item.
if (dropEffect == DragDropEffects.Move) {
ListDragSource.Items.RemoveAt(indexOfItemUnderMouseToDrag);
// Selects the previous item in the list as long as the list has an item.
if (indexOfItemUnderMouseToDrag > 0)
ListDragSource.SelectedIndex = indexOfItemUnderMouseToDrag -1;
else if (ListDragSource.Items.Count > 0)
// Selects the first item.
ListDragSource.SelectedIndex =0;
}
// Dispose of the cursors since they are no longer needed.
if (MyNormalCursor != null)
MyNormalCursor.Dispose();
if (MyNoDropCursor != null)
MyNoDropCursor.Dispose();
}
}
}
}
private void ListDragSource_GiveFeedback(object sender, System.Windows.Forms.GiveFeedbackEventArgs e)
{
// Use custom cursors if the check box is checked.
if (UseCustomCursorsCheck.Checked) {
// Sets the custom cursor based upon the effect.
e.UseDefaultCursors = false;
if ((e.Effect DragDropEffects.Move) == DragDropEffects.Move)
Cursor.Current = MyNormalCursor;
else
Cursor.Current = MyNoDropCursor;
}
}
private void ListDragTarget_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
// Determine whether string data exists in the drop data. If not, then
// the drop effect reflects that the drop cannot occur.
if (!e.Data.GetDataPresent(typeof(System.String))) {
e.Effect = DragDropEffects.None;
DropLocationLabel.Text = "None - no string data.";
return;
}
// Set the effect based upon the KeyState.
if ((e.KeyState (8+32)) == (8+32)
(e.AllowedEffect DragDropEffects.Link) == DragDropEffects.Link) {
// KeyState 8 + 32 = CTL + ALT
// Link drag-and-drop effect.
e.Effect = DragDropEffects.Link;
} else if ((e.KeyState 32) == 32
(e.AllowedEffect DragDropEffects.Link) == DragDropEffects.Link) {
// ALT KeyState for link.
e.Effect = DragDropEffects.Link;
} else if ((e.KeyState 4) == 4
(e.AllowedEffect DragDropEffects.Move) == DragDropEffects.Move) {
// SHIFT KeyState for move.
e.Effect = DragDropEffects.Move;
} else if ((e.KeyState 8) == 8
(e.AllowedEffect DragDropEffects.Copy) == DragDropEffects.Copy) {
// CTL KeyState for copy.
e.Effect = DragDropEffects.Copy;
} else if ((e.AllowedEffect DragDropEffects.Move) == DragDropEffects.Move) {
// By default, the drop action should be move, if allowed.
e.Effect = DragDropEffects.Move;
} else
e.Effect = DragDropEffects.None;
// Get the index of the item the mouse is below.
// The mouse locations are relative to the screen, so they must be
// converted to client coordinates.
indexOfItemUnderMouseToDrop =
ListDragTarget.IndexFromPoint(ListDragTarget.PointToClient(new Point(e.X, e.Y)));
// Updates the label text.
if (indexOfItemUnderMouseToDrop != ListBox.NoMatches){
DropLocationLabel.Text = "Drops before item #" + (indexOfItemUnderMouseToDrop + 1);
} else
DropLocationLabel.Text = "Drops at the end.";
}
private void ListDragTarget_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// Ensure that the list item index is contained in the data.
if (e.Data.GetDataPresent(typeof(System.String))) {
Object item = (object)e.Data.GetData(typeof(System.String));
// Perform drag-and-drop, depending upon the effect.
if (e.Effect == DragDropEffects.Copy ||
e.Effect == DragDropEffects.Move) {
// Insert the item.
if (indexOfItemUnderMouseToDrop != ListBox.NoMatches)
ListDragTarget.Items.Insert(indexOfItemUnderMouseToDrop, item);
else
ListDragTarget.Items.Add(item);
}
}
// Reset the label text.
DropLocationLabel.Text = "None";
}
private void ListDragSource_QueryContinueDrag(object sender, System.Windows.Forms.QueryContinueDragEventArgs e) {
// Cancel the drag if the mouse moves off the form.
ListBox lb = sender as ListBox;
if (lb != null) {
Form f = lb.FindForm();
// Cancel the drag if the mouse moves off the form. The screenOffset
// takes into account any desktop bands that may be at the top or left
// side of the screen.
if (((Control.MousePosition.X - screenOffset.X) f.DesktopBounds.Left) ||
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) ||
((Control.MousePosition.Y - screenOffset.Y) f.DesktopBounds.Top) ||
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom)) {
e.Action = DragAction.Cancel;
}
}
}
private void ListDragTarget_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) {
// Reset the label text.
DropLocationLabel.Text = "None";
}
private void ListDragTarget_DragLeave(object sender, System.EventArgs e) {
// Reset the label text.
DropLocationLabel.Text = "None";
}
}
}

對用這種拖放操作和微軟的服務(wù),容器模式的關(guān)系,留在以后再學(xué)習(xí)。

標(biāo)簽:許昌 信陽 朔州 西雙版納 孝感 自貢 常州 萊蕪

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net DoDragDrop 方法的使用》,本文關(guān)鍵詞  asp.net,DoDragDrop,方法,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net DoDragDrop 方法的使用》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net DoDragDrop 方法的使用的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃
    国产欧美一区二区三区在线老狼| 在线观看日韩国产| 北条麻妃一区二区三区| 99国产一区二区三精品乱码| 欧美揉bbbbb揉bbbbb| 欧美电影免费观看高清完整版在| 欧美激情一区二区三区四区| 亚洲免费av观看| 久久99这里只有精品| 99视频有精品| 91.xcao| 国产日产亚洲精品系列| 亚洲国产成人av| 国产九色sp调教91| 欧洲人成人精品| 久久免费电影网| 亚洲自拍都市欧美小说| 国产在线看一区| 欧美亚洲国产bt| 久久亚洲精精品中文字幕早川悠里 | 日韩一区二区三区电影| 中文字幕精品—区二区四季| 偷窥国产亚洲免费视频| 成人国产一区二区三区精品| 日韩一卡二卡三卡四卡| 综合亚洲深深色噜噜狠狠网站| 日韩黄色小视频| 99久久免费国产| 欧美精品一区二区三区很污很色的| 亚洲黄色免费电影| 国产精品一区二区你懂的| 欧美美女一区二区| 中文字幕日本乱码精品影院| 蜜桃视频在线观看一区| 欧美性猛交xxxx乱大交退制版 | 国产福利一区二区三区在线视频| 欧美日韩一区二区三区在线| 国产精品色一区二区三区| 男人的j进女人的j一区| 91福利资源站| 国产精品成人免费精品自在线观看| 免费欧美在线视频| 在线观看国产日韩| 国产精品久久久久aaaa樱花| 久久精品久久99精品久久| 欧洲亚洲精品在线| 亚洲图片激情小说| 成人a免费在线看| 久久久久国产精品人| 日产国产欧美视频一区精品 | 亚洲国产综合色| 欧美一区二区三区四区五区 | 91在线精品一区二区三区| wwww国产精品欧美| 七七婷婷婷婷精品国产| 欧美日韩三级视频| 亚洲精品自拍动漫在线| 不卡的看片网站| 国产亚洲综合在线| 国产乱码字幕精品高清av| 欧美va亚洲va在线观看蝴蝶网| 日韩成人伦理电影在线观看| 欧美三级日韩在线| 亚洲chinese男男1069| 日本高清无吗v一区| 亚洲欧美视频在线观看| 不卡视频在线观看| 国产精品久久久久久久久快鸭| 懂色av一区二区三区免费看| 国产三区在线成人av| 精品一区二区三区免费播放| 欧美电视剧免费全集观看| 麻豆精品国产91久久久久久| 91精品视频网| 免费不卡在线观看| 欧美一区二区国产| 九一久久久久久| 久久久久国产成人精品亚洲午夜| 精彩视频一区二区三区| 2024国产精品| 国产馆精品极品| 国产精品国模大尺度视频| 成人午夜免费电影| 亚洲婷婷在线视频| 欧美揉bbbbb揉bbbbb| 青草av.久久免费一区| 日韩午夜激情av| 国产中文一区二区三区| 国产精品视频你懂的| 99精品视频一区二区三区| 亚洲精品欧美激情| 欧美高清视频不卡网| 精品一区二区三区视频在线观看| 久久女同性恋中文字幕| 99久久精品国产一区二区三区 | 欧美久久久久久久久久| 看国产成人h片视频| 久久久久久**毛片大全| 99麻豆久久久国产精品免费| 亚洲永久精品大片| 日韩久久久精品| 成人免费视频视频在线观看免费| 亚洲欧美激情小说另类| 欧美久久婷婷综合色| 国产尤物一区二区| 亚洲视频中文字幕| 欧美疯狂性受xxxxx喷水图片| 麻豆精品视频在线| 国产精品初高中害羞小美女文| 欧美伊人精品成人久久综合97| 日本系列欧美系列| 国产欧美日韩在线视频| 欧美亚洲高清一区二区三区不卡| 蜜臀精品久久久久久蜜臀 | 欧美精品在线观看一区二区| 国模娜娜一区二区三区| 18欧美亚洲精品| 欧美一区二区三区视频免费播放| 国产91精品入口| 五月天激情小说综合| 久久一留热品黄| 91麻豆国产福利精品| 日本视频一区二区三区| 亚洲欧洲一区二区在线播放| 欧美一区二区女人| 972aa.com艺术欧美| 捆绑调教美女网站视频一区| 亚洲女人的天堂| 2020国产精品| 欧美日韩成人激情| 成人免费高清视频在线观看| 日本不卡一区二区三区高清视频| 日韩毛片视频在线看| 精品久久久久久亚洲综合网 | 午夜私人影院久久久久| 中文字幕免费不卡| 69堂成人精品免费视频| 99综合影院在线| 精品一区二区在线看| 亚洲黄网站在线观看| 日本一区二区久久| 精品国产一区二区三区四区四| 欧美三级午夜理伦三级中视频| 成人免费观看视频| 韩国成人福利片在线播放| 午夜久久久久久电影| 中文字幕在线播放不卡一区| 久久综合999| 日韩一本二本av| 欧美视频中文字幕| 色综合天天综合| 国产成人亚洲综合a∨猫咪| 日韩在线一二三区| 一区二区三区免费| 亚洲日本在线天堂| 国产精品系列在线| 久久久久久电影| 精品国产一二三| 欧美一区二区三区视频免费播放 | 亚洲成人自拍一区| 亚洲免费色视频| 国产精品美女www爽爽爽| 亚洲精品在线三区| 欧美一二三区精品| 在线播放欧美女士性生活| 欧美亚洲国产一区在线观看网站 | 亚洲综合一区二区精品导航| 国产精品久久久久久久久搜平片| 久久无码av三级| 久久婷婷国产综合精品青草| 日韩精品一区二区三区在线播放| 3d成人动漫网站| 欧美美女激情18p| 欧美日韩不卡一区二区| 欧美日韩精品一区二区| 欧美在线你懂的| 欧美专区亚洲专区| 91精品91久久久中77777| 91麻豆.com| 91丨九色porny丨蝌蚪| 色综合久久久网| 91免费在线视频观看| 在线免费视频一区二区| 在线一区二区观看| 欧洲另类一二三四区| 欧美日韩国产美| 6080亚洲精品一区二区| 91精品婷婷国产综合久久竹菊| 欧美一区二区三区精品| 欧美电影免费观看高清完整版在| 欧美mv和日韩mv的网站| 精品国产凹凸成av人网站| 国产亚洲短视频| 17c精品麻豆一区二区免费| 亚洲一线二线三线视频| 亚洲影院在线观看| 日韩不卡手机在线v区| 精品一区二区国语对白| 国产成人在线视频网址| eeuss鲁片一区二区三区|